Being a powershell rookie, I had some trouble with getting some info from IIS 6 for a deployment script I am working on. I wanted to get the path name of a web site so I can place app_offline.htm prior to deployment. Here’s how I can get the target path:
$server = "localhost"
$siteName = "MySiteName"
$iis = [ADSI]"IIS://$server/W3SVC"
$site = $iis.psbase.children | where {$_.schemaClassName -eq "IIsWebServer" -AND $_.ServerComment -eq $siteName}
$path = $site.psbase.children | where {$_.name -eq 'root'}
$path.path
I am not sure how brittle this is, but it seems to work.
References
Posted
04-29-2010 7:25 AM
by
Michael Nichols