2

appcmd.exeを使用してIISの状態を監視するスクリプトを作成したいのですが、サイトがダウンしている場合はサイトを再起動し、ダウンしている場合はIISを再起動します。

これはPowerShellで実行できますか?これを行うためのより自然で簡単な方法はありますか?

ありがとう :-)

4

2 に答える 2

13

Windows PowerShellは常に答えです!これはあなたの特定の質問のためにそれをするべきです:

# Cycle IIS if it's not running    
Get-Service W3SVC  |
    Where-Object {$_.Status -ne 'Running' }  | 
    Start-Service

Import-Module WebAdministration

# Cycle websites that are not started
Get-Website | 
    Where-Object { $_.State -ne 'Started' }  | 
    ForEach-Object { $_.Start() } 

お役に立てれば

于 2011-12-21T21:27:22.257 に答える
0

このWebAdministrationモジュールを使用すると、appcmdを使用するよりも洗練された方法でそれを行うことができます。

http://technet.microsoft.com/en-us/library/ee790599.aspx

于 2011-12-21T21:16:58.133 に答える