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