1. Can you try this again, don't forget to change the $server and $siteName
variables to match your criteria :
$server = "localhost"
$siteName = "default web site"
$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
2. To get access to the contents of your iis server you point it to the W3SVC
container.
PS > $iis = [ADSI]"IIS://$server/W3SVC"
When you list the children (I'm selecting path only for bravity), you 'll
see something similar to:
PS > $iis.psbase.children | ft path
Path
----
IIS://localhost/W3SVC/Info
IIS://localhost/W3SVC/Filters
IIS://localhost/W3SVC/1
IIS://localhost/W3SVC/2
IIS://localhost/W3SVC/3
The last three rows (e.g W3SVC/1..3) denotes websites (the number is the
site index). You may see more (or less) if you're IIs has more then three
websites.
Typically, the first one (W3SVC/1) is associated with the "Default Web Site".
Exploring this as a starting point to [ADSI] shows:
PS > $iis = [ADSI]"IIS://$server/W3SVC/1"
PS > $iis.psbase.children | ft path
path
----
{c:\inetpub\wwwroot}
IIS://localhost/W3SVC/1/IIsCertMapper
The first row is the path to the site root folder (i.e ROOT container) and
is equivalent to :
PS > $iis = [ADSI]"IIS://$server/W3SVC/1/ROOT"
PS > $iis.path
C:\Inetpub\wwwroot
I have this book and I find it very usefull:
Windows NT/2000 ADSI Scripting for System Administration
http://my.safaribooksonline.com/1578702194
Also check the Script Repository: Internet Information Server 6.0
http://www.microsoft.com/technet/scr....mspx?mfr=true
---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
G> Thanks Shay,
G>
G> 1.
G>
G> I have tried that your 2nd solution works but the 1st one does not
G> work (there is no output from command $path.path), any ideas to do
G> further analysis?
G>
G> 2.
G>
G> I want to learn more about like what does W3SVC or W3SVC/1/ROOT mean
G> in IIS? Any reference to follow up learning?
G>
G> regards,
G> George


