public IEnumerable <VMSwitch> Post(VMSwitch sw) { string str = string.Format("$sw = Get-VMSwitch -Id {0}\r\nRemove-VMSwitch $sw -Force", sw.Id); PSHelper.RunScript(str); return(base.Get()); }
public IEnumerable <VMSwitch> Post(VMSwitch sw) { string empty = string.Empty; string[] strArrays = new string[] { "Private", "Internal" }; if (strArrays.Contains <string>(sw.SwitchType)) { string str = "New-VMSwitch -Name {1} -ComputerName {0} -Notes {3} -SwitchType {4}"; object[] hyperVHost = new object[] { sw.HyperVHost, sw.Name, sw.Notes, sw.SwitchType }; empty = string.Format(str, hyperVHost); } else if (!string.IsNullOrWhiteSpace(sw.NetAdapterInterfaceDescription)) { string str1 = "New-VMSwitch -Name {1} -ComputerName {0} -Notes {3} -InterfaceDecription {4}"; object[] objArray = new object[] { sw.HyperVHost, sw.Name, sw.Notes, sw.NetAdapterInterfaceDescription }; empty = string.Format(str1, objArray); } if (!string.IsNullOrWhiteSpace(empty)) { PSHelper.RunScript(empty); } return(base.Get()); }
public async Task <int> Deploy(string folderToDeployPath, string defaultServerLocation, string serverName, string folderName, bool?backup, bool?overwrite, int delaySeconds) { var folderToDeployToPath = Util.PrepareDeployToPath(serverName, defaultServerLocation, folderName); await PSHelper.RunScript(PSHelper.GetSiteOperationScript(serverName, folderName, SiteOperation.Stop)); await Logger.Log($"Starting in {delaySeconds} seconds to ensure process is dead so files won't be locked.", true); await Util.Delay(delaySeconds); if (backup == true) { await Logger.Log("Creating backup", true); await CreateBackup(folderToDeployToPath, folderName); } await Logger.Log($"Starting deployment to: {folderToDeployToPath}", true); await AsyncIO.HandleFilesAndFoldersAsync(folderToDeployPath, folderToDeployToPath, overwrite); await Logger.Log($"Completed deployment to: {folderToDeployToPath}", true); await PSHelper.RunScript(PSHelper.GetSiteOperationScript(serverName, folderName, SiteOperation.Start)); return(1); }
public string Post(VMInfo Id) { string str = string.Format(this.ScriptPattern, Id.HyperVHost, Id.Id); return(PSHelper.RunScript(str)); }