/// <summary> /// Run a powershell cmdlet that returns the first PSObject as a return value. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="cmdlet"></param> /// <returns></returns> private T RunPSCmdletAndReturnFirst <T>(PowershellCore.CmdletsInfo cmdlet) { WindowsAzurePowershellCmdlet azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(cmdlet); Collection <PSObject> result = azurePowershellCmdlet.Run(); if (result.Count == 1) { return((T)result[0].BaseObject); } return(default(T)); }
/// <summary> /// Run a powershell cmdlet that returns a collection of PSObjects as a return value. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="cmdlet"></param> /// <returns></returns> private Collection <T> RunPSCmdletAndReturnAll <T>(PowershellCore.CmdletsInfo cmdlet) { WindowsAzurePowershellCmdlet azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(cmdlet); Collection <PSObject> result = azurePowershellCmdlet.Run(); Collection <T> resultCollection = new Collection <T>(); foreach (PSObject re in result) { resultCollection.Add((T)re.BaseObject); } return(resultCollection); }
public void Add(CmdletsInfo cmdlet) { this.cmdlets.Add(cmdlet); }
public PowershellCmdlet(CmdletsInfo cmdlet) : base() { this.cmdlet = cmdlet; }
public PowershellCmdlet(CmdletsInfo cmdlet, params PowershellModule[] modules) : base(modules) { this.cmdlet = cmdlet; }
public WindowsAzurePowershellCmdlet(CmdletsInfo cmdlet) : base(cmdlet, ConstructModules()) { }