omnipower321
asked on
Powershell WMI for IIS7/7.5 reporting
Hello,
I have been tasked to put together a reporting script to gather several attributes from several IIS instances on several servers using several versions of IIS. The script needs to be able to run from any location with a vanilla PowerShell configuration loaded. I have it working fine and gathering all needed attribues using:
Get-WmiObject -Namespace "root\WebAdministration" -Class Site -Authentication PacketPrivacy -ComputerName x
Get-WmiObject -NameSpace "root\WebAdministration" -Class VirtualDirectory -Authentication PacketPrivacy -ComputerName x
I can find the site name, physical directory pathm log directory path, site binding information along with other details, but I cannot find the AppPoolID.
In IIS 6 I used to gather this with an ADSI connection or with System.DirectoryServices.D irectoryEn try("IIS:/ /server/W3 SVC/1/root ") but this does not appear to work with a 7.5 instance not in compatability mode.
Where can I find the AppPoolID in the root\WebAdministration namespace?
Thank you.
I have been tasked to put together a reporting script to gather several attributes from several IIS instances on several servers using several versions of IIS. The script needs to be able to run from any location with a vanilla PowerShell configuration loaded. I have it working fine and gathering all needed attribues using:
Get-WmiObject -Namespace "root\WebAdministration" -Class Site -Authentication PacketPrivacy -ComputerName x
Get-WmiObject -NameSpace "root\WebAdministration" -Class VirtualDirectory -Authentication PacketPrivacy -ComputerName x
I can find the site name, physical directory pathm log directory path, site binding information along with other details, but I cannot find the AppPoolID.
In IIS 6 I used to gather this with an ADSI connection or with System.DirectoryServices.D
Where can I find the AppPoolID in the root\WebAdministration namespace?
Thank you.
ASKER
Thank you for the response. I am able to get the data I need from the microsoftiisv2 namespace in IIS6 or 7 in compatibility mode, but it is an invalid namespace on IIS7/7.5 in "regular mode". Same as the adsi.
Not sure if you are going in blind or not but this tool has been very useful for me building WMI scripts around Primal Forms. http://thepowershellguy.com/blogs/posh/archive/2007/03/22/powershell-wmi-explorer-part-1.aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Data was only available in root/webadministration for native IIS 7/7.5 where as it was combined in the site object in microsoftiisv2.
Open in new window
The VirtualDirecory class returns this set of properties:
Open in new window
To get a broader search, try using the namespace \microsoftiisv2 with the class iiswebserversetting. The properties pulled back by this search will return these fields:
Open in new window
Within this set of data you can find a lot of good info. Also, check out my blog post, particularly about using the PSBase and PSBase.GetRelated() sections. You can get a lot of very interesting relationships within the classes this way and do not have to be stuck within a single class:
http://learningpcs.blogspo
Using this namespace, I can find a good bit, but, not all of the info you're after:
Open in new window