简体   繁体   中英

PowerShell Installing additional tools and use cmdlets installed

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.

Thank you mike z,

I found an other work around, I'm using the Invoke-Command ( http://technet.microsoft.com/en-us/library/hh849719.aspx )

With this way, I can perform all actions in the same PowerShell script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM