Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ps.Commands.AddCommand("Get-Command");
- InitialSessionState initial = InitialSessionState.CreateDefault();
- initial.ImportPSModule(new string[] {@"C:Program FilesMicrosoft Application VirtualizationClientAppvClientAppvClient.psd1" });
- ps.Commands.AddCommand("Import-Module").AddArgument("AppvClient");
- public static void powershellCommand()
- {
- Collection<PSObject> result;
- using (Runspace myRunSpace = RunspaceFactory.CreateRunspace())
- {
- InitialSessionState initial = InitialSessionState.CreateDefault();
- initial.ImportPSModule(new string[] {@"C:Program FilesMicrosoft Application VirtualizationClientAppvClientAppvClient.psd1" });
- Runspace runspace = RunspaceFactory.CreateRunspace(initial);
- runspace.Open();
- PowerShell ps = PowerShell.Create();
- ps.Runspace = runspace;
- ps.Commands.AddCommand("Import-Module").AddArgument("AppvClient");
- ps.Commands.AddCommand("Get-AppvVirtualProcess");
- result = ps.Invoke();
- var builder = new StringBuilder();
- foreach (PSObject psObject in result)
- {
- builder.Append(psObject.ToString() + "n");
- builder.ToString();
- }
- Console.WriteLine("Virtual Process: {0}", builder.ToString());
- }
- }
- public static void p()
- {
- using (var powershell = PowerShell.Create())
- {
- powershell.AddCommand("Get-AppvVirtualProcess");
- powershell.Invoke();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement