Windows巡检IIS指标脚本(PowerShell实现)

匿名 (未验证) 提交于 2019-12-02 23:39:01
 function WriteLog([string]  $content){      #Write-Host $content     $script:OutMessage += $content + "`r`n" }  Import-Module WebAdministration  #获取所有Application Pools #WriteLog "Start checking IIS application pool..."    #  开始检查IIS应用程序池  Get-ChildItem IIS:\apppools | ForEach-Object{     $appPoolName =  $_.Name     $appPool = $_     #检查回收设置     $RecyclingTime = $appPool.recycling.periodicRestart.time.TotalMinutes     #检查账号设置     $identityType = $appPool.processModel.identityType     $userName = $appPool.processModel.userName     #生成回收事件日志设置     $LogEventOnRecycle = $appPool.recycling.logEventOnRecycle     #把Idle Timeout设为0     $IdleTimeout = $appPool.processModel.idleTimeout     #最大工作进程数设置为0,支持NUMA     $maxProcesses = $appPool.processModel.maxProcesses }  WriteLog('[{"IIS application name":{"value":"' + $_.name + '","unit":"","status":"0"}},' + '{"IIS Automatic recovery cycle":{"value":"' + $RecyclingTime + '","unit":"","status":"0"}},' + '{"IIS account type":{"value":"' + $identityType + '","unit":"","status":"0"}},' + '{"IIS LogEventOnRecycle":{"value":"' + $LogEventOnRecycle + '","unit":"","status":"0"}},' + '{"IIS IdleTimeout":{"value":"' + $IdleTimeout + '","unit":"","status":"0"}},' + '{"IIS maxProcesses":{"value":"' + $maxProcesses + '","unit":"","status":"0"}}]')  Get-ChildItem IIS:\Sites | ForEach-Object{     $site = $_ }  $OutMessage

文章来源: https://blog.csdn.net/sinat_28371057/article/details/91381725
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!