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);
|
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)
|
private void CreateDrivesXmlEmpty(string path, string fileName)
|
||||||
{
|
{
|
||||||
DirectoryInfo drivesDirectory = new DirectoryInfo(path);
|
DirectoryInfo drivesDirectory = new DirectoryInfo(path);
|
||||||
|
@ -1745,15 +1753,27 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
{
|
{
|
||||||
HostedSolutionLog.LogStart("OpenRunspace");
|
HostedSolutionLog.LogStart("OpenRunspace");
|
||||||
|
|
||||||
|
bool isModulesImported = true;
|
||||||
|
|
||||||
if (runspaceConfiguration == null)
|
if (runspaceConfiguration == null)
|
||||||
{
|
{
|
||||||
runspaceConfiguration = RunspaceConfiguration.Create();
|
runspaceConfiguration = RunspaceConfiguration.Create();
|
||||||
|
|
||||||
|
isModulesImported = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Runspace runSpace = RunspaceFactory.CreateRunspace(runspaceConfiguration);
|
Runspace runSpace = RunspaceFactory.CreateRunspace(runspaceConfiguration);
|
||||||
//
|
//
|
||||||
runSpace.Open();
|
runSpace.Open();
|
||||||
//
|
//
|
||||||
runSpace.SessionStateProxy.SetVariable("ConfirmPreference", "none");
|
runSpace.SessionStateProxy.SetVariable("ConfirmPreference", "none");
|
||||||
|
|
||||||
|
if (!isModulesImported)
|
||||||
|
{
|
||||||
|
ImportGroupPolicyMolude(runSpace);
|
||||||
|
ImportActiveDirectoryMolude(runSpace);
|
||||||
|
}
|
||||||
|
|
||||||
HostedSolutionLog.LogEnd("OpenRunspace");
|
HostedSolutionLog.LogEnd("OpenRunspace");
|
||||||
return runSpace;
|
return runSpace;
|
||||||
}
|
}
|
||||||
|
@ -1765,6 +1785,7 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
if (runspace != null && runspace.RunspaceStateInfo.State == RunspaceState.Opened)
|
if (runspace != null && runspace.RunspaceStateInfo.State == RunspaceState.Opened)
|
||||||
{
|
{
|
||||||
runspace.Close();
|
runspace.Close();
|
||||||
|
//runspaceConfiguration = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue