I'm wondering if someone can explain to me a difference in behavior that I'm seeing.

I'm trying to find the physical path of an IIS site.

This sample works, correctly returning the PhysicalPath

Import-Module WebAdministration
Get-ChildItem iis:\\sites | Select PhysicalPath

This sample doesn't work. The PhysicalPath is returned as null / empty.

Get-IISSite | select PhysicalPath

If I'm correct, both the samples should be returning a Microsoft.Web.Administration.Site object. Why is the second one missing data?


Let's see:

Get-ChildItem iis:\sites | get-Member | Where name -like p* | Sort-Object Name

    TypeName: System.Object

 Name          MemberType   Definition
 ----          ----------   ----------
 password      NoteProperty string password=
 physicalPath  NoteProperty string physicalPath=C:\inetpub\wwwroot
 PSChildName   NoteProperty string PSChildName=Default Web Site
 PSDrive       NoteProperty PSDriveInfo PSDrive=IIS
 PSIsContainer NoteProperty bool PSIsContainer=True
 PSParentPath  NoteProperty string PSParentPath=WebAdministration::\\SANKNIGHT\Sites
 PSPath        NoteProperty string PSPath=WebAdministration::\\SANKNIGHT\Sites\Default Web Site
 PSProvider    NoteProperty IIsProviderInfo PSProvider=WebAdministration

Get-IISSite | get-Member

    TypeName: Microsoft.Web.Administration.Site

 Name                       MemberType            Definition
 ----                       ----------            ----------
 ApplicationDefaults        Property              Microsoft.Web.Administration.ApplicationDefaults ApplicationDefault...
 Applications               Property              Microsoft.Web.Administration.ApplicationCollection Applications {get;}
 Attributes                 Property              Microsoft.Web.Administration.ConfigurationAttributeCollection Attri...
 Bindings                   Property              Microsoft.Web.Administration.BindingCollection Bindings {get;}
 ChildElements              Property              Microsoft.Web.Administration.ConfigurationChildElementCollection Ch...
 Delete                     Method                void Delete()

it doesn't have any members starting with P and has far fewer members than Get-ChildItem. You can see they are not the same object either.

When using Get-ChildItem, each provider provides some hints on what should be displayed. I think this is in:


because of this, all the extra information is added.

  • Yes, and for the output of "Get-IISSite" the PhysicalPath is derived from $_.Applications["/"].VirtualDirectories["/"].PhysicalPath – Sebazzz Mar 29 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.