Powershell获取IIS应用程序初始化状态
问题描述:
我的网站有doAppInitAfterRestart
设置为true
并且正在工作,但我想知道应用程序何时完成初始化。Powershell获取IIS应用程序初始化状态
有没有办法通过powershell
和WMI
知道网站的应用程序初始化何时完成?
答
请尝试下面提到的VB脚本代码。我从我的一个工作脚本中删除了这段代码,如果发现任何错误,请发表评论。
iis_con= "localhost"
set WMI_IIS = GetObject("IIS://" & iis_con & "/W3SVC")
if WMI_IIS.count = 0 then
' do nothing
else
for each objitem in WMI_IIS
if objitem.class = "IIsWebServer" then
Select Case objItem.serverstate
Case 1: wscript.echo("Starting")
Case 2: wscript.echo("Running")
Case 3: wscript.echo("Stopping")
Case 4: wscript.echo("Stopped")
Case 5: wscript.echo("Pausing")
Case 6: wscript.echo("Paused")
Case 7: wscript.echo("Continuing")
Case Default: wscript.echo("Unknown")
End Select
Next
end if
感谢您的帮助@Amit。不完全符合我的要求。 立即在站点(少于一秒)启动后,此代码开始并继续返回“2”运行状态。 以下是转换为我用来测试的powershell的代码。 while($ true){ $ site = get-wmiobject -namespace“root \ MicrosoftIISv2”-class“IIsWebServer”-ComputerName localhost -Filter“name ='w3svc/4'” $ site.serverstate start-sleep - 毫秒10 } – lovedatsnow
我不知道你使用的是IIS6 +,所以没有提供WMI。那么你现在面临什么问题?我没有完全了解你的评论。 –
是的,我正在使用IIS6 +。我仍然无法确定应用初始化完成的时间。 – lovedatsnow