Link to home
Start Free TrialLog in
Avatar of omnipower321
omnipower321Flag for United States of America

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.DirectoryEntry("IIS://server/W3SVC/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.
Avatar of wls3
wls3
Flag of United States of America image

The site class only returns this set of properties:

__GENUS                   
__CLASS                   
__SUPERCLASS              
__DYNASTY                 
__RELPATH                 
__PROPERTY_COUNT          
__DERIVATION              
__SERVER                  
__NAMESPACE               
__PATH                    
ApplicationDefaults       
Bindings                  
FtpServer                 
Id                        
Limits                    
LogFile                   
Name                      
ServerAutoStart           
TraceFailedRequestsLogging
VirtualDirectoryDefaults

Open in new window

 

The VirtualDirecory class returns this set of properties:

__GENUS          
__CLASS          
__SUPERCLASS     
__DYNASTY        
__RELPATH        
__PROPERTY_COUNT 
__DERIVATION     
__SERVER         
__NAMESPACE      
__PATH           
AllowSubDirConfig
ApplicationPath  
LogonMethod      
Password         
Path             
PhysicalPath     
SiteName         
UserName

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:

__GENUS
__CLASS
__SUPERCLASS
__DYNASTY
__RELPATH
__PROPERTY_COUNT
__DERIVATION
__SERVER
__NAMESPACE
__PATH
AccessExecute
AccessFlags
AccessNoPhysicalDir
AccessNoRemoteExecute
AccessNoRemoteRead
AccessNoRemoteScript
AccessNoRemoteWrite
AccessRead
AccessScript
AccessSource
AccessSSL
AccessSSL128
AccessSSLFlags
AccessSSLMapCert
AccessSSLNegotiateCert
AccessSSLRequireCert
AccessWrite
AdminACLBin
AllowKeepAlive
AllowPathInfoForScriptMappings
AnonymousPasswordSync
AnonymousUserName
AnonymousUserPass
AppAllowClientDebug
AppAllowDebugging
AppFriendlyName
AppOopRecoverLimit
AppPoolId
AppWamClsid
AspAllowOutOfProcComponents
AspAllowSessionState
AspAppServiceFlags
AspBufferingLimit
AspBufferingOn
AspCalcLineNumber
AspCodepage
AspDiskTemplateCacheDirectory
AspEnableApplicationRestart
AspEnableAspHtmlFallback
AspEnableChunkedEncoding
AspEnableParentPaths
AspEnableSxs
AspEnableTracker
AspEnableTypelibCache
AspErrorsToNTLog
AspExceptionCatchEnable
AspExecuteInMTA
AspKeepSessionIDSecure
AspLCID
AspLogErrorRequests
AspMaxDiskTemplateCacheFiles
AspMaxRequestEntityAllowed
AspPartitionID
AspProcessorThreadMax
AspQueueConnectionTestTime
AspQueueTimeout
AspRequestQueueMax
AspRunOnEndAnonymously
AspScriptEngineCacheMax
AspScriptErrorMessage
AspScriptErrorSentToBrowser
AspScriptFileCacheSize
AspScriptLanguage
AspScriptTimeout
AspSessionMax
AspSessionTimeout
AspSxsName
AspTrackThreadingModel
AspUsePartition
AuthAdvNotifyDisable
AuthAnonymous
AuthBasic
AuthChangeDisable
AuthChangeUnsecure
AuthFlags
AuthMD5
AuthNTLM
AuthPassport
AuthPersistence
AuthPersistSingleRequest
AzEnable
AzImpersonationLevel
AzScopeName
AzStoreName
Bindings
CacheControlCustom
CacheControlMaxAge
CacheControlNoCache
CacheISAPI
Caption
CertCheckMode
CGITimeout
ClusterEnabled
ConnectionTimeout
ContentIndexed
CreateCGIWithNewConsole
CreateProcessAsUser
DefaultDoc
DefaultDocFooter
DefaultLogonDomain
Description
DirBrowseFlags
DirBrowseShowDate
DirBrowseShowExtension
DirBrowseShowLongDate
DirBrowseShowSize
DirBrowseShowTime
DisableSocketPooling
DisableStaticFileCache
DoDynamicCompression
DontLog
DoStaticCompression
EnableDefaultDoc
EnableDirBrowsing
EnableDocFooter
EnabledProtocols
EnableReverseDns
FrontPageWeb
HttpCustomHeaders
HttpErrors
HttpErrorsExistingResponse
HttpExpires
HttpPics
LogExtFileBytesRecv
LogExtFileBytesSent
LogExtFileClientIp
LogExtFileComputerName
LogExtFileCookie
LogExtFileDate
LogExtFileFlags
LogExtFileHost
LogExtFileHttpStatus
LogExtFileHttpSubStatus
LogExtFileMethod
LogExtFileProtocolVersion
LogExtFileReferer
LogExtFileServerIp
LogExtFileServerPort
LogExtFileSiteName
LogExtFileTime
LogExtFileTimeTaken
LogExtFileUriQuery
LogExtFileUriStem
LogExtFileUserAgent
LogExtFileUserName
LogExtFileWin32Status
LogFileDirectory
LogFileLocaltimeRollover
LogFilePeriod
LogFileTruncateSize
LogOdbcDataSource
LogOdbcPassword
LogOdbcTableName
LogOdbcUserName
LogonMethod
LogPluginClsid
LogType
MaxBandwidth
MaxBandwidthBlocked
MaxConnections
MaxEndpointConnections
MaxRequestEntityAllowed
MimeMap
Name
NTAuthenticationProviders
PassportRequireADMapping
PasswordCacheTTL
PasswordChangeFlags
PasswordExpirePrenotifyDays
PoolIdcTimeout
ProcessNTCRIfLoggedOn
Realm
RedirectHeaders
RevocationFreshnessTime
RevocationURLRetrievalTimeout
ScriptMaps
SecureBindings
ServerAutoStart
ServerBindings
ServerCommand
ServerComment
ServerListenBacklog
ServerListenTimeout
ServerSize
SetHostName
SettingID
ShutdownTimeLimit
SSIExecDisable
SSLAlwaysNegoClientCert
SslCtlIdentifier
SslCtlStoreName
SSLStoreName
TraceUriPrefix
UploadReadAheadSize
UseDigestSSP
UseHostName
Win32Error

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.blogspot.com/2010/11/wmic-namespace.html

Using this namespace, I can find a good bit, but, not all of the info you're after:

gwmi -namespace root\microsoftiisv2 -class "iiswebserversetting" -filter "servercomment='Powershell Site'" | select name, path, logfiledirectory, bindings, apppoolid | ft -auto

Open in new window

Avatar of omnipower321

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.
Avatar of garrett_boarder
garrett_boarder

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
Avatar of omnipower321
omnipower321
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Data was only available in root/webadministration for native IIS 7/7.5 where as it was combined in the site object in microsoftiisv2.