[英]How to remotely stop/start an application pool in IIS 8
Caveat: using one line each! 警告:每个使用一行!
I had these commands for use in IIS 6, and they worked just fine. 我有这些命令在IIS 6中使用,他们工作得很好。
Start: 开始:
(get-wmiobject -namespace 'root\MicrosoftIISv2' -computername 'REMOTE_SERVER' -class 'IIsApplicationPool' | where-object {$_.Name -eq 'W3SVC/AppPools/MY_FANCY_APPPOOL'}).InvokeMethod('Stop', $null)"
-and- -和-
Stop: 停止:
(get-wmiobject -namespace 'root\MicrosoftIISv2' -computername 'REMOTE_SERVER' -class 'IIsApplicationPool' | where-object {$_.Name -eq 'W3SVC/AppPools/MY_FANCY_APPPOOL'}).InvokeMethod('Start', $null)
I'm looking for an alternative in IIS 8. I need a couple of one-liners and they must be Powershell commands. 我正在寻找IIS 8中的替代方案。我需要几个单行程序,它们必须是Powershell命令。 I'm invoking them via a
InvokePowerShellCommand
activity in TFS. 我正在通过TFS中的
InvokePowerShellCommand
活动调用它们。 Is there anyone out there who can help me out? 那里有谁可以帮助我吗?
You can do the following to start your application pool : 您可以执行以下操作来启动应用程序池:
Invoke-Command -ComputerName "REMOTE_SERVER" -ScriptBlock { Start-WebAppPool -Name "MY_FANCY_APPPOOL" }
You can do the following to stop your application pool : 您可以执行以下操作来停止应用程序池:
Invoke-Command -ComputerName "REMOTE_SERVER" -ScriptBlock { Stop-WebAppPool -Name "MY_FANCY_APPPOOL" }
To start, sometimes you need to add an explicit wait so that the app pool responds to control messages: 首先,有时您需要添加显式等待,以便应用程序池响应控制消息:
Invoke-Command -ComputerName "$REMOTE_SERVER" -ScriptBlock { Import-Module WebAdministration; Start-Sleep -s 10; Start-WebAppPool -Name "$APP_POOL_NAME" }
And to stop: 并停止:
Invoke-Command -ComputerName "$REMOTE_SERVER" -ScriptBlock { Import-Module WebAdministration; Stop-WebAppPool -Name "$APP_POOL_NAME" }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.