## Re: how to get IIS web site directory

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"
\$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.

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.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.path
C:\Inetpub\wwwroot

I have this book and I find it very usefull:

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>