[英]PowerShell Installing additional tools and use cmdlets installed
I am installing some MSI package in a powershell script like that : 我正在像这样的Powershell脚本中安装一些MSI软件包:
Start-Process "Msi_Path" /qn -Wait
启动进程“ Msi_Path” / qn-等待
these MSI package are : 这些MSI软件包是:
SQLSysClrTypes.msi,SharedManagementObjects.msi,PowerShellTools.msi (For SQL Server 2012) SQLSysClrTypes.msi,SharedManagementObjects.msi,PowerShellTools.msi(对于SQL Server 2012)
In the same script, after installation, I am trying to import the SqlPs module like that : 在相同的脚本中,安装后,我试图像这样导入SqlPs模块:
Import-Module SqlPs -DisableNameChecking
导入模块SqlPs -DisableNameChecking
But I got this error : 但是我得到了这个错误:
The specified module 'SQLPS' was not loaded becuase no valid file was found in any module directory.
未加载指定的模块“ SQLPS”,因为在任何模块目录中均未找到有效文件。
When I open a new PowerShell windows and import the module it's works. 当我打开一个新的PowerShell窗口并导入该模块时,它就起作用了。 I tried to start a new PowerShell process in my script like that :
我试图像这样在脚本中启动新的PowerShell进程:
Start-Process 'powershell' 'secondScript.ps1' #with Import-Module SqlPs
使用Import-Module SqlPs启动进程'powershell''secondScript.ps1'#
But I got the same error. 但是我遇到了同样的错误。
Did you have any idea or work around ? 您有任何想法或解决方法吗?
Thank you. 谢谢。
Thank you mike z, 谢谢Mike Z,
I found an other work around, I'm using the Invoke-Command ( http://technet.microsoft.com/en-us/library/hh849719.aspx ) 我发现了其他解决方法,正在使用Invoke-Command( http://technet.microsoft.com/en-us/library/hh849719.aspx )
With this way, I can perform all actions in the same PowerShell script. 通过这种方式,我可以在同一PowerShell脚本中执行所有操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.