[英]Can I use PowerShell instead of AppCmd.exe to monitor IIS state?
我想編寫一個使用appcmd.exe監視IIS狀態的腳本 - 如果站點關閉則重新啟動站點,和/或如果IIS關閉則重新啟動IIS。
這可以用powershell完成嗎? 這樣做有更自然/更簡單的方法嗎?
謝謝 :-)
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() }
希望這可以幫助
您可以使用WebAdministration
模塊以比使用appcmd更優雅的方式執行此操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.