Created
September 23, 2023 14:13
-
-
Save rossarioking/03e8d6bffebd3ad6e692d75182f180b6 to your computer and use it in GitHub Desktop.
Powershell Script to Monitor CPU of Remote Host
This file contains hidden or 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
$computerName = "RemoteComputerName" # Replace with the name or IP address of the remote computer | |
$counterPath = "\\$computerName\Processor(_Total)\% Processor Time" | |
# Continuous monitoring loop | |
while ($true) { | |
$cpuUsage = (Get-Counter -Counter $counterPath).CounterSamples.CookedValue | |
Write-Host "CPU Usage on $computerName: $($cpuUsage)%" -ForegroundColor Green | |
Start-Sleep -Seconds 5 # Adjust the sleep interval as needed | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment