Created
February 5, 2020 19:10
-
-
Save Doug-Moody/8ea10598e43e739a4f2c17b12b67bf84 to your computer and use it in GitHub Desktop.
Find the average CPU Mhz over a short period of time. Function
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
#Present the Mhz of a CPU over a short period of time. Quick dirty average of 5 seconds | |
function Get-WorkArea { | |
if (![System.IO.Directory]::Exists("C:\support\")) { | |
[system.io.directory]::CreateDirectory("c:\Support") | |
} | |
if ([System.IO.Directory]::Exists("C:\support\UpToStandard")) { | |
$FileTime = Get-Date -format 'MM.dd.yyyy' | |
$Script:Rando = Get-Random -Maximum 100 | |
Rename-Item -Path "C:\support\UpToStandard" -NewName "C:\support\UpToStandard-$FileTime-$Rando" | |
} | |
if (![System.IO.Directory]::Exists("C:\support\UpToStandard")) { | |
[system.io.directory]::CreateDirectory("c:\Support\UpToStandard") | |
} | |
} | |
Get-WorkArea | |
# Center a menu border | |
function CenterText { | |
param($Message) | |
$string = "# " | |
for ($i = 0; $i -lt (([Math]::Max(0, $Host.UI.RawUI.BufferSize.Width / 2) - [Math]::Max(0, $Message.Length / 2))) - 4; $i++) { | |
$string = $string + " " | |
} | |
$string = $string + $Message | |
for ($i = 0; $i -lt ($Host.UI.RawUI.BufferSize.Width - ((([Math]::Max(0, $Host.UI.RawUI.BufferSize.Width / 2) - [Math]::Max(0, $Message.Length / 2))) - 2 + $Message.Length)) - 2; $i++) { | |
$string = $string + " " | |
} | |
$string = $string + " #" | |
return $string | |
} | |
# Check CPU Performance over short time | |
function Get-CPUMhz { | |
function Write-OutputCenter { param($Message) Write-Output ("{0}{1}" -f (' ' * (([Math]::Max(0, $Host.UI.RawUI.BufferSize.Width / 2) - [Math]::Floor($Message.Length / 2)))), $Message) } | |
Write-OutputCenter | |
Clear-Host | |
CenterText "##########################################################################################" | |
CenterText "" | |
CenterText "One moment as system CPU performance is checked" | |
CenterText "" | |
CenterText "##########################################################################################" | |
$results = @(1..5) | ForEach-Object { | |
Get-CimInstance win32_processor | Select-Object -First 1 -ExpandProperty currentclockspeed | |
Start-Sleep 1 | |
} | |
(Get-CimInstance –class Win32_processor).NumberOfLogicalProcessors | |
$Script:cpuMhz = ($results | Measure-Object -Average | Select-Object -ExpandProperty Average) | |
if ($cpuMhz -le 850) { | |
$Script:cpuStatus = "Slow CPU Issue" | |
$Script:miscStatus = "Needs Attention" | |
} | |
else { | |
$Script:cpuStatus = "CPU Throttle goes above minimum" | |
} | |
} | |
Get-CPUMhz | |
Write-Host ("Recent Average CPU Speed Detected: $($cpuMhz)Mhz") -ForegroundColor Green | |
$cpuStatus |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment