Esempio n. 1
0
        /// <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));
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
 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;
 }
Esempio n. 6
0
 public PowershellCmdlet(CmdletsInfo cmdlet) : base()
 {
     this.cmdlet = cmdlet;
 }
Esempio n. 7
0
 public PowershellCmdlet(CmdletsInfo cmdlet, params PowershellModule[] modules) : base(modules)
 {
     this.cmdlet = cmdlet;
 }
 public void Add(CmdletsInfo cmdlet)
 {
     this.cmdlets.Add(cmdlet);
 }
 public WindowsAzurePowershellCmdlet(CmdletsInfo cmdlet)
     : base(cmdlet, ConstructModules())
 {
 }