Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                RemotePowerShellClient client = new RemotePowerShellClient("PowerShellClient");

                Console.WriteLine("Press any key to start");
                Console.ReadKey();
                Console.WriteLine();

                string startResponse = client.StartPowerShell(Providers, PerfCounters);
                Console.Write(startResponse);

                RestartIis(client, "test1");

                string command;
                do
                {
                    command = Console.ReadLine();
                    ExecuteCommand(client, command);
                } while (!string.Equals("exit", command, StringComparison.InvariantCultureIgnoreCase));

                client.Close();
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.ToString());
            }

            Console.WriteLine("\n\nPress any key to exit");
            Console.ReadKey();
        }
Exemplo n.º 2
0
 private static void ExecuteCommandBatch(RemotePowerShellClient client, string[] commands)
 {
     foreach (string command in commands)
     {
         ExecuteCommand(client, command);
     }
 }
Exemplo n.º 3
0
 private static void ExecuteCommand(RemotePowerShellClient client, string cmd)
 {
     string commandResponse = client.SendCommand(cmd);
     Console.WriteLine(commandResponse);
 }
Exemplo n.º 4
0
 private static void StopPerfCounters(RemotePowerShellClient client)
 {
     ExecuteCommandBatch(client, new string[] {
         @"logman stop infrastructure_counters",
         @"logman delete infrastructure_counters",
         @"copy .\*.blg $testOutputDir",
     });
 }
Exemplo n.º 5
0
 private static void StartPerfCounters(RemotePowerShellClient client)
 {
     ExecuteCommandBatch(client, new string[] {
         @"del perfcounters*.blg",
         @"logman create counter infrastructure_counters -cf perfCounters.txt -si 1 -o perfcounters.blg",
         @"logman start infrastructure_counters",
     });
 }
Exemplo n.º 6
0
 private static void RestartIis(RemotePowerShellClient client, string testName)
 {
     ExecuteCommandBatch(client, new string[] {
         string.Format(@"$testOutputDir = $perfOutputDir + ""\{0}""", testName),
         @"iisreset",
         @"net start w3svc",
     });
 }