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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With