Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var rs = RunspaceFactory.CreateRunspace();
- rs.Open();
- // create a pipeline to add the variable into the runspace
- var pipeline = PowerShell.Create();
- // create a command object, add commands and parameters to it...
- var cmd = new PSCommand();
- cmd.AddCommand("New-Variable");
- cmd.AddParameter("Name", "foo");
- cmd.AddParameter("Value", "@()");
- // associate the command with the pipeline and runspace, and then invoke
- pipeline.Commands = cmd;
- pipeline.Runspace = rs;
- pipeline.Invoke();
- cmd.AddParameter("Value", new object[0]);
- pipeline.Runspace.SessionStateProxy.PSVariable.Set("foo", new object[0]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement