我正在尝试为我们的一些服务器打印以下格式: [服务器] | [SITENAME] | [appPoolName] | [appPoolState] | [appPoolRecycleSchedule]
这是我到目前为止所得到的:
$Pool = Get-ChildItem IIS:\AppPools
foreach ( $p in $Pool )
{
$app_pool = $p.Name
$timing = Get-ItemProperty IIS:\\AppPools\$app_pool -name recycling.periodicRestart.schedule.collection
Write-Host "$($compName)|$($app_pool)|$($p.state)|$($timing.value)"
}
如何在此处获取网站名称?
谢谢, 阿伦
答案 0 :(得分:0)
我能够做到这一点 - 感谢一大堆网站!
$Pool = Get-ChildItem IIS:\AppPools
foreach ( $p in $Pool )
{
$app_pool = $p.Name
$apps = (Get-WebConfigurationProperty "/system.applicationHost/sites/site/application[`
@applicationPool='$app_pool']" "machine/webroot/apphost" -name path).ItemXPath
$site = ''
foreach ($s in $apps) {
$name = $s -replace "\/system.applicationHost\/sites\/site\[\@name='", ""
$name = $name -replace "' and \@id='\d{1,10}'\]\/application\[\@path='", ""
$name = $name -replace "'\]",""
if($site -eq ''){
$site = $name
}
else{
$site = $site + ", " + $name
}
}
if($site -eq "")
{
$site = "NotFound"
}
$timing = Get-ItemProperty IIS:\\AppPools\$app_pool -name recycling.periodicRestart.schedule.collection
Write-Host "$($compName)|$($app_pool)|$($p.state)|$($timing.value)|$($site)"
}