如何在c#中的Powershell运行空间中指定“noProfile”

时间:2017-04-10 16:36:56

标签: c# powershell runspace

我有一个在c#中运行powershell命令的应用程序。我希望我的运行空间在运行我的应用程序时不加载用户的配置文件。这是我的代码初始化运行空间:

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;

有什么想法吗?

0 个答案:

没有答案