Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Management.Automation;
- namespace PowerShellExt
- {
- public static class Execution
- {
- public static void ExecutePS(this string script)
- {
- var result = PowerShell
- .Create()
- .AddScript(script)
- .AddCommand("Out-String")
- .Invoke();
- foreach (var item in result)
- {
- System.Console.WriteLine(item);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment