帮助我重写PowerShell脚本以获取Windows 7和Windows 2008(IIS6)上IIS应用程序池的状态。
function Get-AppPool {
[CmdletBinding()]
param
(
[string[]]$Server,
[String]$Pool
)
#region loadAssembly
[Reflection.Assembly]::LoadWithPartialName('Microsoft.Web.Administration')
#endregion loadAssembly
foreach ($s in $server)
{
$sm = [Microsoft.Web.Administration.ServerManager]::OpenRemote($s)
$apppools = $sm.ApplicationPools["$pool"]
$status = $apppools.state
$info = @{
'Pool Name'=$pool;
'Status'=$status;
'Server'=$S;
}
Write-Output (New-Object –Typename PSObject –Prop $info)
}
}
答案 0 :(得分:0)
如果您只需要从当前计算机获取应用程序池的状态,请尝试以下操作:
Import-Module WebAdministration
Get-WebAppPoolState -Name 'DefaultAppPool'