这个问题是从这一事实出现以后,服务器2014 Management Studio中的安装添加新路径到$env:PSModulePath
C:\Users\BLANCJP\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules\
不过,在最初的代码假设POSH服务器模块是最后的安装:
...
# Test Module Paths
Foreach ($ModulePath in $ModulePaths)
{
$ModulePath = "$ModulePath\PoSHServer"
$ModulePath = $ModulePath.Replace("\\","\")
$PoSHModulePathTest = Test-Path $ModulePath
if ($PoSHModulePathTest)
{
$PoSHModulePath = $ModulePath
}
}
}
if (!$PoSHModulePathTest)
{
Write-Warning "Could not detect PoSH Server Module Path."
...
我刚才添加的暂停指令有我的辣妹再次合作
...
# Test Module Paths
Foreach ($ModulePath in $ModulePaths)
{
$ModulePath = "$ModulePath\PoSHServer"
$ModulePath = $ModulePath.Replace("\\","\")
$PoSHModulePathTest = Test-Path $ModulePath
if ($PoSHModulePathTest)
{
$PoSHModulePath = $ModulePath
break
}
}
}
if (!$PoSHModulePathTest)
{
Write-Warning "Could not detect PoSH Server Module Path."
...