Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Management.Automation;
  7. using System.Collections.ObjectModel;
  8.  
  9. namespace ConsoleApplication1
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             PowerShell ps = PowerShell.Create();
  16.             ps.AddCommand("Get-Process");
  17.             Collection<PSObject> results = ps.Invoke();
  18.             foreach (PSObject result in results)
  19.             {
  20.                 if (result != null)
  21.                 {
  22.                     Console.WriteLine(result.ToString());
  23.                 }
  24.             }
  25.             Console.Read();
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement