PowerShell - Performance Metrics

preview_player
Показать описание
(How to get remote performance metrics, like CPU, memory, disk and Networking)
In this video I show you how the get-counter cmdlet works. With this cmdlet you are able to tap live into the performance metrics of your local machine, or a remote machine. (Provided you have access to that remote machine of course)

*get-counter
*get performance information from remote system
*get performance counter from remote system
*get CPU usage
*get memory usage
*get disk usage
*get network usage
*powershell
*learn powershell
*automation
*learn automation
*windows powershell

Code :

#man Get-Counter

#Get-Counter -ListSet * | ogv
#Get-Counter -ListSet * | where countersetname -eq processor | select -ExpandProperty counter
$servername = "hv02"
#$cred = Get-Credential

while($true){
Invoke-Command -ComputerName $servername -ScriptBlock {
$cpu = Get-Counter -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 1 -MaxSamples 1
$mem = Get-Counter -Counter "\Memory\Committed Bytes" -SampleInterval 1 -MaxSamples 1
$nic = Get-Counter -Counter "\Network Interface(*)\Bytes Total/sec" -SampleInterval 1 -MaxSamples 1
$disk = Get-Counter -Counter "\PhysicalDisk(*)\Disk Bytes/sec" -SampleInterval 1 -MaxSamples 1
$prop = @{
#servername = $servername
cpu = $cpu.CounterSamples.CookedValue
mem = $mem.CounterSamples.CookedValue
nic = $nic.CounterSamples.CookedValue
disk = $disk.CounterSamples.CookedValue
}
New-Object psobject -Property $prop
} -Credential $cred

Start-Sleep -Seconds 2
}
Рекомендации по теме
Комментарии
Автор

Publishing on a rainy Sunday afternoon. Not a bad idea! With weather like this, people only want to be inside and watch something useful. Thnx for sharing Mark!

emgiwoodworks
Автор

Amazing video, Thanks for helping with my video request.

hasnainnajafi