I am installing some MSI package in a powershell script like that :
Start-Process "Msi_Path" /qn -Wait
these MSI package are :
SQLSysClrTypes.msi,SharedManagementObjects.msi,PowerShellTools.msi (For SQL Server 2012)
In the same script, after installation, I am trying to import the SqlPs module like that :
Import-Module SqlPs -DisableNameChecking
But I got this error :
The specified module 'SQLPS' was not loaded becuase no valid file was found in any module directory.
When I open a new PowerShell windows and import the module it's works. I tried to start a new PowerShell process in my script like that :
Start-Process 'powershell' 'secondScript.ps1' #with Import-Module SqlPs
But I got the same error.
Did you have any idea or work around ?
Thank you.
Start-Process
with-UseNewEnvironment
? Module paths are defined in environment variables which are not changed while the process is running. I believeStart-Process
uses the parent process's environment by default. – Mike Zboray