test fix of adding powershell modules
This commit is contained in:
parent
720fa486d1
commit
9cb2cdd511
1 changed files with 21 additions and 0 deletions
|
@ -1566,6 +1566,14 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
ExecuteShellCommand(runSpace, cmd);
|
||||
}
|
||||
|
||||
private void ImportActiveDirectoryMolude(Runspace runSpace)
|
||||
{
|
||||
Command cmd = new Command("Import-Module");
|
||||
cmd.Parameters.Add("Name", "ActiveDirectory");
|
||||
|
||||
ExecuteShellCommand(runSpace, cmd);
|
||||
}
|
||||
|
||||
private void CreateDrivesXmlEmpty(string path, string fileName)
|
||||
{
|
||||
DirectoryInfo drivesDirectory = new DirectoryInfo(path);
|
||||
|
@ -1745,15 +1753,27 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
{
|
||||
HostedSolutionLog.LogStart("OpenRunspace");
|
||||
|
||||
bool isModulesImported = true;
|
||||
|
||||
if (runspaceConfiguration == null)
|
||||
{
|
||||
runspaceConfiguration = RunspaceConfiguration.Create();
|
||||
|
||||
isModulesImported = false;
|
||||
}
|
||||
|
||||
Runspace runSpace = RunspaceFactory.CreateRunspace(runspaceConfiguration);
|
||||
//
|
||||
runSpace.Open();
|
||||
//
|
||||
runSpace.SessionStateProxy.SetVariable("ConfirmPreference", "none");
|
||||
|
||||
if (!isModulesImported)
|
||||
{
|
||||
ImportGroupPolicyMolude(runSpace);
|
||||
ImportActiveDirectoryMolude(runSpace);
|
||||
}
|
||||
|
||||
HostedSolutionLog.LogEnd("OpenRunspace");
|
||||
return runSpace;
|
||||
}
|
||||
|
@ -1765,6 +1785,7 @@ namespace WebsitePanel.Providers.HostedSolution
|
|||
if (runspace != null && runspace.RunspaceStateInfo.State == RunspaceState.Opened)
|
||||
{
|
||||
runspace.Close();
|
||||
//runspaceConfiguration = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue