-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
30 lines (26 loc) · 765 Bytes
/
Program.cs
File metadata and controls
30 lines (26 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Collections.ObjectModel;
using System.Management.Automation;
namespace PSNoWindow
{
public class Program
{
public static void Main(string[] args)
{
PSDataCollection<PSObject> results;
using (PowerShell ps = PowerShell.Create())
{
var script = @".\Get-AllTechnicians.ps1";
ps.AddScript(File.ReadAllText(script));
ps.AddParameter("User", "me");
IAsyncResult asyncres = ps.BeginInvoke();
do
{
//Wait
}
while (!asyncres.IsCompleted);
results = ps.EndInvoke(asyncres);
}
}
}
}