0
我可以得到當前位置信息作爲PowerShell將站點指向新位置。
#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")
如何設置這個新的位置是網站的定位?
謝謝。
這導致了下面的錯誤。看起來問題是Physicalpath。 由於參數「obj」的值爲空,無法處理參數。將參數「obj」的 [08:24:28]值更改爲非空值。 [08:24:28] + CategoryInfo:InvalidArgument:(:) [Set-ItemProperty],PSArgum [08:24:28] entNullException [08:24:28] + FullyQualifiedErrorId:InvalidArgument,Microsoft.PowerShell.Commands .Se [08:24:28] tItemPropertyCommand – 2014-09-23 13:29:40
嘗試修改後的答案。 – Raf 2014-09-23 13:38:27
這一次是這個錯誤:您必須在' - '運算符的右側提供值表達式。 [08:49:18]在C:\ TeamCity \ buildAgent \ work \ CopyBuildOutpu [08:49:18] tToStagingServers.ps1:80 char:9 [08:49:18] +} - <<<<參數列表$目錄名 [8時49分18秒] + CategoryInfo:ParserError:(:) [],ParentContainsErrorRecordEx [8時49分18秒] ception [8時49分18秒] + FullyQualifiedErrorId:ExpectedValueExpression – 2014-09-23 13:52:45