str*_*rum 2 iis powershell appcmd
我想编写一个使用appcmd.exe监视IIS状态的脚本 - 如果站点关闭则重新启动站点,并且如果站点关闭则重新启动IIS.
这可以用powershell完成吗?这样做有更自然/更简单的方法吗?
谢谢 :-)
Sta*_*ing 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() }
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助
| 归档时间: |
|
| 查看次数: |
2916 次 |
| 最近记录: |