Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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()
like image 287
Karl Glennon Avatar asked Dec 01 '08 11:12

Karl Glennon


1 Answers

$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()
like image 168
Karl Glennon Avatar answered Sep 28 '22 00:09

Karl Glennon