這個問題是從這一事實出現以後,服務器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."
...