我编写了一个PowerShell脚本来自动部署IIS网站,但是当我将参数传递给脚本时,我收到以下错误:
找不到驱动器。名为“IIS”的驱动器不存在。
我的脚本(iss_website_version_update.ps1
)如下所示,但请注意它还没有完成:
param(
[array]$iishostlist=$(throw "Parameter missing: -name iishostlist"),
[array]$websiteName=$(throw "Parameter missing: -name websiteName")
)
For($i=0;$i -lt $iishostlist.Count; $i++){
For($j=0;$j -lt $websiteName.Count; $j++){
$start = get-date
$tempSession = new-pssession -ComputerName $($iishostlist[$i])
Invoke-Command -Session $tempSession -ScriptBlock {
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -command Import-Module WebAdministration;set-location IIS:\;(Stop-Website $($websiteName[$j]))
}
.......
请让我知道为什么命令set-location IIS:\;
中的子命令 Invoke-Command
不被识别?
发布于 2018-07-13 18:09:08
我有个模拟问题。错误是我没有在Admin模式下运行脚本。
https://stackoverflow.com/questions/-100005577
复制相似问题