以编程方式确定 IIS 站点是否正在运行
我有一个脚本,可以收集 IIS 中的所有站点,并通过电子邮件发送一些详细信息以供审核。我想调整它,以便它只向正在运行的网站发送电子邮件。我不需要知道被停止的网站。我已经引用了 IIS 中的所有 DirectoryEntry
,但我没有看到任何指示它是否正在运行的属性。
这是怎么做到的?理想情况下,它应该在 IIS6 和 IIS7 上运行。
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 DirectoryEntry
s 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DirectoryEntry.Properties
集合包含一个ServerState
属性。它没有很好地记录,但我发现 这个博主 创建了他自己的枚举,这似乎是正确的。枚举是使用此逻辑来检查
DirectoryEntry
是否正在运行,您可以使用:The
DirectoryEntry.Properties
collection, contains aServerState
property. 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
DirectoryEntry
is running, you would use: