Windows system up time and high CPU usage processes

 Windows system up time

Invoke-Command -ScriptBlock {
	$ut = (get-date) - (gcim Win32_OperatingSystem).LastBootUpTime 
	$tz = [System.TimeZone]::CurrentTimeZone
	Write-Host "`r`nHostname:" $(hostname)
	Write-Host "Timezone:"  $tz.StandardName " / " $tz.DaylightName
	Write-Host "Up time: " $ut.Days " Days " $ut.Hours " Hours " $ut.Minutes " Minutes `r`n"
}

Sample Output:
Hostname: Computer1
Timezone: Romance Standard Time / Romance Daylight Time
Up time: 4 Days 22 Hours 51 Minutes


Get top 5 high CPU usage processes

Get-Process | Sort CPU -descending | Select -first 5 -Property ID, ProcessName, Description, CPU | Format-List
=================================
Expected output
Id          : 2140
ProcessName : chrome
Description : Google Chrome
CPU         : 681.109375

Id          : 7032
ProcessName : mcshield
Description :
CPU         : 649.71875

Id          : 5016
ProcessName : dptf_helper
Description : Intel(R) Dynamic Tuning Utility Application
CPU         : 516.328125



No comments:

Post a Comment

Featured Post

HPE MSA 2040 configuration step by step

HPE MSA 2040 configuration Default IP range for HP SAN storage MSA 2040 is 10.0.0.1/2 You need to connect your laptop and storage with...