Created
February 18, 2019 15:49
-
-
Save clintcolding/c160c8bfebf49bc539e0a7f3346f7f4e to your computer and use it in GitHub Desktop.
Gets Windows server resource usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Invoke-Command -ComputerName $server -Credential $cred { | |
$npmem = Get-Counter -Counter "\Memory\Pool Nonpaged Bytes" -MaxSamples 1 -SampleInterval 1 | |
[PSCustomObject]@{ | |
Hostname = $env:COMPUTERNAME | |
"w3wp(MB)" = [math]::Round((Get-Process w3wp | Measure-Object WorkingSet -Sum).sum / 1MB,2) | |
"NonPaged(GB)" = [math]::Round($npmem.CounterSamples.cookedvalue / 1gb,2) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach ($server in $servers.hostname[0]) { | |
Invoke-Command -ComputerName $server -Credential $cred { | |
$available = Get-Counter '\Memory\Available MBytes' | |
$total = (Get-WmiObject -class "cim_physicalmemory" | Measure-Object -Property Capacity -Sum).Sum / 1MB | |
$used = $total - $available.CounterSamples.CookedValue | |
[PSCustomObject]@{ | |
Hostname = $env:COMPUTERNAME | |
Memory = [math]::Round($used / $total,2) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment