• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3848
  • Last Modified:

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.
0
omnipower321
Asked:
omnipower321
  • 3
1 Solution
 
wls3Commented:
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

0
 
omnipower321Author Commented:
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.
0
 
garrett_boarderCommented:
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
0
 
omnipower321Author Commented:
Was able to get the information needed out of:

namespace root\WebAdministration class Site
namespace root\WebAdministration class VirtualDirectory
namespace root\WebAdministration class Application

I had to use common attributes between them to match them up.
0
 
omnipower321Author Commented:
Data was only available in root/webadministration for native IIS 7/7.5 where as it was combined in the site object in microsoftiisv2.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now