简体   繁体   中英

Changing IIS6 Site Home Directory with Powershell

I'm trying to change a site's home directory using powershell. This is what I have so far, but it isn't saving the changes...

$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()
$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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM