コード例 #1
0
        static void Main(string[] args)
        {
            PSFactory myPowershell = new PSFactory();

            if (myPowershell.openRunspace("dpfadmin", "Express10n!", "corpnet", "bil-corp12.corpnet.liox.org"))
            {
                // Start Basic and run a simple command in the runspace
                WriteResult(myPowershell.RunScript(new List <string> {
                    "Get-Service", "Get-Host"
                }));

                // Now, lets try our AD Utilities Library
                // Return the BitLocker Recover Keys for a System

                IEnumerable <BitLocker_KeySet> computerKeys = Bitlocker.Get_ADBitLockerRecoveryKeys(myPowershell, "BAL-DF-E6500");
                foreach (BitLocker_KeySet keySet in computerKeys)
                {
                    Console.WriteLine("Date Created : {0}", keySet.KeyDate);
                    Console.WriteLine("Machine ID   : {0}", keySet.MachineID);
                    Console.WriteLine("Recovery Key : {0}", keySet.RecoveryKey);
                }

                // Clean up Afterwards
                myPowershell.closeRunspace();
            }
            ////;

            ////WriteResult(myPowershell.RunScript(new List<string> { "hostname | write-host" }));
            ////WriteResult(myPowershell.RunScript(new List<string> { "a=1+2" }));


            //myPowershell.closeRunspace();
        }
コード例 #2
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            //response.WithFiltering().PublishRange(runCommand(request.Inputs["Computer Name"].AsString()));

            string strComputer = request.Inputs["Computer Name"].AsString();

            PSFactory myPowershell = new PSFactory();

            if (myPowershell.openRunspace(connection.UserName, connection.Password, connection.Domain, connection.Host))
            {
                IEnumerable <BitLocker_KeySet> computerKeys = Bitlocker.Get_ADBitLockerRecoveryKeys(myPowershell, "BAL-DF-E6500");
                int numKeys = response.WithFiltering().PublishRange(computerKeys);
                response.Publish("Number of Keys", numKeys);

                myPowershell.closeRunspace();
            }
        }
コード例 #3
0
        public static IEnumerable <WU_RebootStatus> Get_RebootStatus(PSFactory psRunspace, string strComputer)
        {
            // Create a Dictionary to store the results
            List <Dictionary <string, string> > results;

            // Execute our Query
            results = psRunspace.RunScript(new List <string> {
                "New-Object -ComObject 'Microsoft.Update.SystemInfo'"
            });
            foreach (var entry in results)
            {
                if (entry.ContainsKey("RebootRequired"))
                {
                    string rebootRequired = entry["RebootRequired"];
                    yield return(new WU_RebootStatus(rebootRequired));
                }
            }
        }
コード例 #4
0
ファイル: Bitlocker.cs プロジェクト: DamianFlynn/Orchestrator
        public static IEnumerable <BitLocker_KeySet> Get_ADBitLockerRecoveryKeys(PSFactory psRunspace, string strComputer)
        {
            // First  Load up our Powershell Resources (Modules and Functions)
            string fileContent = Resources.Get_ADBitLockerRecoveryKeys;

            // Create a Dictionary to store the results
            List <Dictionary <string, string> > results;

            // Execute our Query
            results = psRunspace.RunScript(new List <string> {
                fileContent, "Get-BitLockerRecoveryKey -Computer " + strComputer
            });
            foreach (var entry in results)
            {
                if (entry.ContainsKey("RecoveryPassword"))
                {
                    string canonicalName    = entry["CanonicalName"];
                    string recoveryPassword = entry["RecoveryPassword"];
                    yield return(new BitLocker_KeySet(canonicalName, recoveryPassword));
                }
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: DamianFlynn/Orchestrator
        static void Main(string[] args)
        {
            PSFactory myPowershell = new PSFactory();

            if (myPowershell.openRunspace("dpfadmin", "Express10n!", "corpnet", "bil-corp12.corpnet.liox.org"))
            {
                // Start Basic and run a simple command in the runspace
                WriteResult(myPowershell.RunScript(new List <string> {
                    "Get-Service", "Get-Host"
                }));

                // Now, lets try our AD Utilities Library
                // Return the BitLocker Recover Keys for a System

                IEnumerable <WU_RebootStatus> rebootState = WU_Activities.Get_RebootStatus(myPowershell, "BAL-DF-E6500");
                foreach (WU_RebootStatus computerRebootState in rebootState)
                {
                    Console.WriteLine("Pending Reboot : {0}", computerRebootState.PendingReboot);
                }

                // Clean up Afterwards
                myPowershell.closeRunspace();
            }
        }