使用Powershell更改IIS6站点主目录

Kar*_*non 6 iis powershell scripting iis-6

我正在尝试使用PowerShell更改站点的主目录.这是我到目前为止,但它没有保存更改...

$server = "localhost"
$siteName = "mysite"
$iis = [ADSI]"IIS://$server/W3SVC"
$site = $iis.psbase.children | where { $_.keyType -eq "IIsWebServer" 
        -AND $_.ServerComment -eq $siteName }
$path = [adsi]($site.psbase.path+"/ROOT")

$path.path = "D:\Sites\mysite\www2"
$site.psbase.CommitChanges()
Run Code Online (Sandbox Code Playgroud)

Kar*_*non 12

$server = "localhost"
$siteName = "mysite"
$iis = [ADSI]"IIS://$server/W3SVC"
$site = $iis.psbase.children | where { $_.keyType -eq "IIsWebServer" 
        -AND $_.ServerComment -eq $siteName }
$path = [adsi]($site.psbase.path+"/ROOT")
$path.path
$path.psbase.properties.path[0] = "D:\Sites\$siteName\www2"
$path.path
$path.psbase.CommitChanges()
Run Code Online (Sandbox Code Playgroud)

  • Powershell脚本,可在单台计算机上使用ARR实现零停机部署:https://github.com/yosoyadri/IIS-ARR-Zero-Downtime/blob/master/DeployLocalFarm.ps1 (2认同)