2

I have an application that's running powershell commands in c#. I want my runspace to NOT load the user's profile when they run my app. Here's my code that initializes the runspace:

var iss = InitialSessionState.CreateDefault();
iss.AuthorizationManager = new AuthorizationManager(Guid.NewGuid().ToString());

var host = new CustomHost(Append);
_runspace = RunspaceFactory.CreateRunspace(host, iss);
_runspace.ThreadOptions = PSThreadOptions.UseCurrentThread;

_runspace.ApartmentState = ApartmentState.STA;
_runspace.Open();

Runspace.DefaultRunspace = _runspace;

Any ideas?

Ethan Eiter
  • 101
  • 9

0 Answers0