PowerShell - Performance Metrics

Published: 20 February 2022
on channel: Mr Automation
846
25

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)

*How to get (remote) performance metrics, like CPU, memory, disk and Networking
*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
}


Watch video PowerShell - Performance Metrics online, duration hours minute second in high quality that is uploaded to the channel Mr Automation 20 February 2022. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 846 times and liked it 25 visitors.