I have a script that gathers up all sites in IIS and emails a few details for auditing. I want to adjust it so that it only emails sites that are running. I do not need to know about sites that are stopped. I already have a reference to all of the DirectoryEntrys in IIS but I don’t see any properties that would indicate if it is running or not.
How is this done? Ideally this should run on both IIS6 and IIS7.
The
DirectoryEntry.Propertiescollection, contains aServerStateproperty. It’s not documented very well but I found this blogger that created his own enumeration which appears to be correct. The enum isUsing this, the logic to check if a
DirectoryEntryis running, you would use: