<# .SYNOPSIS Get the CPU Speed .DESCRIPTION Get the CPU Speed on Linux, MacOS, or Windows .EXAMPLE ./GetCPUSpeed.ps1 #> if ($executionContext.SessionState.PSVariable.Get('IsLinux').Value) { Get-Content /proc/cpuinfo -Raw -ErrorAction SilentlyContinue | Select-String "(?Mhz|MIPS)\s+\:\s+(?[\d\.]+)" | Select-Object -First 1 -ExpandProperty Matches | ForEach-Object { $_.Groups["Value"].Value -as [int] } } elseif ($executionContext.SessionState.PSVariable.Get('IsMacOS').Value) { (sysctl -n hw.cpufrequency) / 1e6 -as [int] } else { $getCimInstance = $ExecutionContext.SessionState.InvokeCommand.GetCommand('Get-CimInstance','Cmdlet') if ($getCimInstance) { & $getCimInstance -Class Win32_Processor | Select-Object -ExpandProperty MaxClockSpeed } }