Powershell and IIS 6.0 Path

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
Filed under: ,

[Advertisement]

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)