public ICustomActivityResult Execute() { string command = "Checkpoint-VM"; using (RemotePowershell rp = new RemotePowershell(UserName, Password, HostName)) { PowerShell ps = rp.powerShell; var results = ps.AddCommand(command) .AddParameters(CreateParameters()) .Invoke(); if (rp.HasError) { throw new Exception(rp.ErrorMessage); } return(this.GenerateActivityResult(SuccessResult())); } }
public ICustomActivityResult Execute() { string command = "Get-VMMemory"; using (RemotePowershell rp = new RemotePowershell(UserName, Password, HostName)) { PowerShell ps = rp.powerShell; var results = ps.AddCommand(command) .AddParameters(CreateParameters()) .Invoke(); if (rp.HasError) { throw new Exception(rp.ErrorMessage); } if (results.Count != 1) { throw new Exception("Can't get virtual machine memory information"); } return(this.GenerateActivityResult(SuccessResult(results[0]))); } }