我可以将当前位置设为
#Connect to webserver1 or webserver2 to find the current location of site, this depends upon powershell remoting being enabled
$Session = New-PSSession -ComputerName $ServerName
Invoke-Command -Session $Session {Add-PSSnapin WebAdministration}
Invoke-Command -Session $Session {Set-Location IIS:\}
$CurrentLocation = Invoke-Command -Session $Session {Get-WebFilePath 'IIS:\Sites\Staging'}
$LogMessage = "Staging site currently located at: " + $CurrentLocation
write-host "##teamcity[message text='$LogMessage']"
我已将更改发布到
$dirname = "\\" + $ServerName + "\d$\inetpub\Staging\Mvc-" + $today.ToString("yyyyMMdd")
如何将此新位置设置为网站位置?
感谢。
答案 0 :(得分:2)
试试这个:
$Session = New-PSSession -ComputerName $ServerName
$dirname = "\\" + $ServerName + "\d$\inetpub\Staging\Mvc-" + $today.ToString("yyyyMMdd")
Invoke-Command -Session $Session -ScriptBlock{
param($dirname)
Add-PSSnapin WebAdministration
Set-ItemProperty 'IIS:\Sites\Staging' -Name physicalPath -Value $dirname
} -ArgumentList $dirname