I wrote a PowerShell script to deploy IIS Website automatically, but when I pass parameters to the script I get the following error:
Cannot find the drive. The drive called 'IIS' does not exist.
My script (iss_website_version_update.ps1
) is as below, but note that it is not finished yet:
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:WindowsSystem32WindowsPowerShellv1.0powershell.exe -NonInteractive -command Import-Module WebAdministration;set-location IIS:;(Stop-Website $($websiteName[$j]))
}
.......
Please let me know why the sub-command set-location IIS:;
in the command Invoke-Command
is not be recognized ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…