コード例 #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));
        }
コード例 #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);
        }
コード例 #3
0
 public void Add(CmdletsInfo cmdlet)
 {
     this.cmdlets.Add(cmdlet);
 }
コード例 #4
0
 public PowershellCmdlet(CmdletsInfo cmdlet)
     : base()
 {
     this.cmdlet = cmdlet;
 }
コード例 #5
0
 public PowershellCmdlet(CmdletsInfo cmdlet, params PowershellModule[] modules)
     : base(modules)
 {
     this.cmdlet = cmdlet;
 }
コード例 #6
0
 public PowershellCmdlet(CmdletsInfo cmdlet) : base()
 {
     this.cmdlet = cmdlet;
 }
コード例 #7
0
 public PowershellCmdlet(CmdletsInfo cmdlet, params PowershellModule[] modules) : base(modules)
 {
     this.cmdlet = cmdlet;
 }
コード例 #8
0
 public void Add(CmdletsInfo cmdlet)
 {
     this.cmdlets.Add(cmdlet);
 }
コード例 #9
0
 public WindowsAzurePowershellCmdlet(CmdletsInfo cmdlet)
     : base(cmdlet, ConstructModules())
 {
 }