Se você não tiver o IIS 7 e o provedor, poderá usar o WMI. O script anexado funciona para a maioria dos seus requisitos, exceto o uso da CPU. Salve o script abaixo como get-webserverapppoolstats.ps1 (ou o que você quiser).
Você pode executar o script com:
./ Get-WebServerAppPoolStats.ps1 'Server1', 'Server2', 'Server3' -IntegratedAuthentication OU Get-Content servers.txt | ./Get-WebServerAppPoolStats.ps1 -IntegratedAuthentication
param (
$webserver = $null,
$username,
$password,
[switch]$IntegratedAuthentication)
BEGIN
{
$path = $MyInvocation.MyCommand.Path
if ($webserver -ne $null)
{
if ($IntegratedAuthentication)
{
$webserver | &$path -IntegratedAuthentication
}
else
{
$webserver | &$path -username $username -password $password
}
}
$OFS = ', '
$Fields = 'CommandLine', 'Name', 'CreationDate', 'ProcessID', 'WorkingSetSize', 'ThreadCount', 'PageFileUsage', 'PageFaults'
$query = @"
Select $fields
From Win32_Process
Where name = 'w3wp.exe'
"@
$AppPool = @{Name='Application Pool';Expression={($_.commandline).split(' ')[-1]}}
$Process = @{Name='Process';Expression={$_.name}}
$RunningSince = @{Name='Running since';Expression={[System.Management.ManagementDateTimeconverter]::ToDateTime($_.creationdate)}}
$Memory = @{Name='Memory Used';Expression={'{0:#,#}' -f $_.WorkingSetSize}}
$Threads = @{Name='Thread Count';Expression={$_.threadcount}}
$PageFile = @{Name='Page File Size';Expression={'{0:#,#}' -f $_.pagefileusage}}
$PageFaults = @{Name='Page Faults';Expression={'{0:#,#}' -f $_.pagefaults}}
}
PROCESS
{
$server = $_
if ($server -ne $null)
{
if ($IntegratedAuthentication)
{
$result = Get-WmiObject -Query $query -ComputerName $server
}
else
{
$securepassword = ConvertTo-SecureString $password -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $securepassword
$result = Get-WmiObject -Query $query -ComputerName $server -Credential $cred
}
$Server = @{Name='Server';Expression={$server}}
$result | Select-Object $Server, $AppPool, $Process, $RunningSince, $Memory, $Threads, $PageFile, $pageFaults
}
}