Public/Diagnostics/Debug-ComputerPerformance.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Debug-ComputerPerformance { <# .SYNOPSIS Analyzes and debugs computer performance across various categories. .DESCRIPTION This function evaluates computer performance in specified categories such as CPU, RAM, Disk, Network, and Internet. It can sort results by rating and format the output. .PARAMETER Category Specifies the performance categories to analyze. Valid values are "CPU", "RAM", "Disk", "Network", and "Internet". .PARAMETER SortByRating Indicates whether to sort the results by rating. .PARAMETER FormatOutput Indicates whether to format the output. .EXAMPLE Debug-ComputerPerformance -Category "CPU","RAM" -SortByRating -FormatOutput Analyzes CPU and RAM performance, sorts the results by rating, and formats the output. .NOTES The function provides a comprehensive analysis of the specified performance categories. #> param( [ValidateSet("CPU","RAM","Disk","Network","Internet")] [String[]]$Category = @("CPU","RAM","Disk","Network","Internet"), [switch]$SortByRating = $false, [switch]$FormatOutput = $false ) $Results = @() $Blank = "" Write-Progress -ID 2 -Activity "Running Performance Tests" -Status "Gathering CPU Data" -PercentComplete 0 IF ($Category -contains "CPU") { ### CPU Information IF ($True) { $CPUResults = Get-CPUDevice $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "CPU" PerformanceItem = "CPU Score" PerformanceResult = $CPUResults.CPUScore PerformanceRating = $CPUResults.CPURating PerformanceRatingString = $CPUResults.CPURatingString } IF ($CPUResults.YearsOld -eq "Unknown") { $AgeRating = $Blank; $AgeRatingString = $Blank } ELSEIF ($CPUResults.YearsOld -le 2) { $AgeRating = 9; $AgeRatingString = "Brand New" } ELSEIF ($CPUResults.YearsOld -le 3) { $AgeRating = 7; $AgeRatingString = "Very New" } ELSEIF ($CPUResults.YearsOld -le 4) { $AgeRating = 5; $AgeRatingString = "Good" } ELSEIF ($CPUResults.YearsOld -le 5) { $AgeRating = 4; $AgeRatingString = "Acceptable" } ELSEIF ($CPUResults.YearsOld -le 6) { $AgeRating = 3; $AgeRatingString = "Old" } ELSEIF ($CPUResults.YearsOld -le 7) { $AgeRating = 2; $AgeRatingString = "Very Old" } ELSE { $AgeRating = 1; $AgeRatingString = "Extremely Old" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "CPU" PerformanceItem = "CPU Age" PerformanceResult = $CPUResults.YearsOld PerformanceRating = $AgeRating PerformanceRatingString = $AgeRatingString } #$CPUUsage = Get-CPUUsage #IF ($CPUUsage -le 20) { $CPUUsageRating = 9; $CPUUsageRatingString = "Crazy Low" } #ELSEIF ($CPUUsage -le 30) { $CPUUsageRating = 8; $CPUUsageRatingString = "Extremely Low" } #ELSEIF ($CPUUsage -le 40) { $CPUUsageRating = 7; $CPUUsageRatingString = "Very Low" } #ELSEIF ($CPUUsage -le 50) { $CPUUsageRating = 6; $CPUUsageRatingString = "Low" } #ELSEIF ($CPUUsage -le 60) { $CPUUsageRating = 5; $CPUUsageRatingString = "Good" } #ELSEIF ($CPUUsage -le 70) { $CPUUsageRating = 4; $CPUUsageRatingString = "Acceptable" } #ELSEIF ($CPUUsage -le 80) { $CPUUsageRating = 3; $CPUUsageRatingString = "High" } #ELSEIF ($CPUUsage -le 90) { $CPUUsageRating = 2; $CPUUsageRatingString = "Very High" } #ELSE { $CPUUsageRating = 1; $CPUUsageRatingString = "Extremely High" } #$Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ # PerformanceCategory = "CPU" # PerformanceItem = "CPU Usage" # PerformanceResult = [string]$CPUUsage + "%" # PerformanceRating = $CPUUsageRating # PerformanceRatingString = $CPUUsageRatingString #} } } Write-Progress -ID 2 -Activity "Running Performance Tests" -Status "Gathering RAM Data" -PercentComplete 10 IF ($Category -contains "RAM") { ### RAM Information IF ($True) { [int]$TotalRAM = Get-RAMTotal $RAMRating = $null IF ($TotalRAM -gt 39) { $RAMRating = 9; $RAMRatingString = "Crazy High" } ELSEIF ($TotalRAM -gt 31) { $RAMRating = 8; $RAMRatingString = "Extremely High" } ELSEIF ($TotalRAM -gt 23) { $RAMRating = 7; $RAMRatingString = "Very High" } ELSEIF ($TotalRAM -gt 19) { $RAMRating = 6; $RAMRatingString = "High" } ELSEIF ($TotalRAM -gt 15) { $RAMRating = 5; $RAMRatingString = "Good" } ELSEIF ($TotalRAM -gt 11) { $RAMRating = 4; $RAMRatingString = "Acceptable" } ELSEIF ($TotalRAM -gt 7) { $RAMRating = 3; $RAMRatingString = "Low" } ELSEIF ($TotalRAM -gt 5) { $RAMRating = 2; $RAMRatingString = "Very Low" } ELSE { $RAMRating = 1; $RAMRatingString = "Extremely Low" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "RAM" PerformanceItem = "RAM Total" PerformanceResult = [string]$TotalRAM + " GB" PerformanceRating = $RAMRating PerformanceRatingString = $RAMRatingString } $AvailableMemoryGBs = [math]::round((Get-CIMInstance Win32_OperatingSystem).FreePhysicalMemory / 1MB,2) IF ($AvailableMemoryGBs -gt 12) { $AvailMemPerformanceRating =9; $AvailMemPerformanceRatingString = "Crazy High" } ELSEIF ($AvailableMemoryGBs -gt 6) { $AvailMemPerformanceRating = 8; $AvailMemPerformanceRatingString = "Extremely High" } ELSEIF ($AvailableMemoryGBs -gt 4) { $AvailMemPerformanceRating = 7; $AvailMemPerformanceRatingString = "Very High" } ELSEIF ($AvailableMemoryGBs -gt 3) { $AvailMemPerformanceRating = 6; $AvailMemPerformanceRatingString = "High" } ELSEIF ($AvailableMemoryGBs -gt 2) { $AvailMemPerformanceRating = 5; $AvailMemPerformanceRatingString = "Good" } ELSEIF ($AvailableMemoryGBs -gt 1.5) { $AvailMemPerformanceRating = 4; $AvailMemPerformanceRatingString = "Acceptable" } ELSEIF ($AvailableMemoryGBs -gt 1) { $AvailMemPerformanceRating = 3; $AvailMemPerformanceRatingString = "Low"} ELSEIF ($AvailableMemoryGBs -gt .5) { $AvailMemPerformanceRating = 2; $AvailMemPerformanceRatingString = "Very Low" } ELSE { $AvailMemPerformanceRating = 1; $AvailMemPerformanceRatingString = "Extremely Low" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "RAM" PerformanceItem = "Available Memory" PerformanceResult = [string]$AvailableMemoryGBs+ " GB" PerformanceRating = $AvailMemPerformanceRating PerformanceRatingString = $AvailMemPerformanceRatingString } } } Write-Progress -ID 2 -Activity "Running Performance Tests" -Status "Running Disk Benchmarks - About 60 Seconds" -PercentComplete 15 IF ($Category -contains "Disk") { $DiskSpd = $True IF (Test-IntegrisFileDependency -RootPath "$ModuleUtilityDir\DiskSpd" -ChildPath "\x86\diskspd.exe" -DownloadURL "https://aka.ms/getdiskspd" -Unzip -Confirm -Force) { $DiskSpd = $False } ### Disk Information IF ($DiskSpd -eq $True) { #$DriveType = Get-DiskDrive | Where-Object { $_.ContainsSystemOS -eq $True } #$Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ # PerformanceCategory = "Disk" # PerformanceItem = "Media Type" # PerformanceResult = $DriveType.MediaType # PerformanceRating = $Blank # PerformanceRatingString = $Blank #} $DiskPerf = Get-DiskPerformance FOREACH ($Perf in $DiskPerf) { $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Disk" PerformanceItem = $Perf.IOType.ToString() + " " + $Perf.AccessType.ToString() PerformanceResult = $Perf.ResultMBs.ToString() + " MB/s" PerformanceRating = $Perf.ResultRating PerformanceRatingString = $Perf.ResultRatingString } } #$Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ # PerformanceCategory = "Disk" # PerformanceItem = "Disk Size" # PerformanceResult = $DriveType.SizeGBs.ToString() + " GB" # PerformanceRating = $Blank # PerformanceRatingString = $Blank #} } ELSE { $DriveType = Get-DiskDrive | Where-Object { $_.ContainsSystemOS -eq $True } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Disk" PerformanceItem = "Media Type" PerformanceResult = $DriveType.MediaType PerformanceRating = $Blank PerformanceRatingString = $Blank } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Disk" PerformanceItem = "Random Read" PerformanceResult = "Unavailable" PerformanceRating = $Blank PerformanceRatingString = $Blank } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Disk" PerformanceItem = "Random Write" PerformanceResult = "Unavailable" PerformanceRating = $Blank PerformanceRatingString = $Blank } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Disk" PerformanceItem = "Sequential Read" PerformanceResult = "Unavailable" PerformanceRating = $Blank PerformanceRatingString = $Blank } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Disk" PerformanceItem = "Sequential Write" PerformanceResult = "Unavailable" PerformanceRating = $Blank PerformanceRatingString = $Blank } } } Write-Progress -ID 2 -Activity "Running Performance Tests" -Status "Gathering Network Data" -PercentComplete 65 IF ($Category -contains "Network") { ### Network Information IF ($True) { $NetworkConnections = Get-NetworkAdapter FOREACH ($NetworkConnection in $NetworkConnections) { IF ($NetworkConnection.Type -like "*WiFi*" -and $NetworkConnection.Status -eq "Connected") { IF([int]$NetworkConnection.SignalStrength.Replace('%','') -ge 95) { $NetPeformanceRating = 9; $NetPerformanceRatingString = "Crazy Stable" } ELSEIF([int]$NetworkConnection.SignalStrength.Replace('%','') -ge 85) { $NetPeformanceRating = 8; $NetPerformanceRatingString = "Extremely Stable" } ELSEIF([int]$NetworkConnection.SignalStrength.Replace('%','') -ge 75) { $NetPeformanceRating = 7; $NetPerformanceRatingString = "Very Stable" } ELSEIF([int]$NetworkConnection.SignalStrength.Replace('%','') -ge 65) { $NetPeformanceRating = 6; $NetPerformanceRatingString = "Stable" } ELSEIF([int]$NetworkConnection.SignalStrength.Replace('%','') -ge 55) { $NetPeformanceRating = 5; $NetPerformanceRatingString = "Good" } ELSEIF([int]$NetworkConnection.SignalStrength.Replace('%','') -ge 45) { $NetPeformanceRating = 4; $NetPerformanceRatingString = "Acceptable" } ELSEIF([int]$NetworkConnection.SignalStrength.Replace('%','') -ge 35) { $NetPeformanceRating = 3; $NetPerformanceRatingString = "Unstable" } ELSEIF([int]$NetworkConnection.SignalStrength.Replace('%','') -ge 25) { $NetPeformanceRating = 2; $NetPerformanceRatingString = "Very Unstable" } ELSE { $NetPeformanceRating = 1; $NetPerformanceRatingString = "Extremely Unstable" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Network" PerformanceItem = "Wireless Signal Strength" PerformanceResult = $NetworkConnection.SignalStrength PerformanceRating = $NetPeformanceRating PerformanceRatingString = $NetPerformanceRatingString } } IF ($NetworkConnection.Status -eq "Connected") { $LinkSpeedCalc = 0 IF ((($NetworkConnection.LinkSpeed.Split('\'))[0] / 4) -lt ($NetworkConnection.LinkSpeed.Split('\'))[1]) { $LinkSpeedCalc = ($NetworkConnection.LinkSpeed.Split('\'))[0] / 4 } ELSE { $LinkSpeedCalc = ($NetworkConnection.LinkSpeed.Split('\'))[1] } IF ($LinkSpeedCalc -gt 250) { $LinkSpeedPerformanceRating = 9; $LinkSpeedPerformanceRatingString = "Crazy Fast" } ELSEIF ($LinkSpeedCalc -gt 175) { $LinkSpeedPerformanceRating = 8; $LinkSpeedPerformanceRatingString = "Extremely Fast" } ELSEIF ($LinkSpeedCalc -gt 115) { $LinkSpeedPerformanceRating = 7; $LinkSpeedPerformanceRatingString = "Very Fast" } ELSEIF ($LinkSpeedCalc -gt 70) { $LinkSpeedPerformanceRating = 6; $LinkSpeedPerformanceRatingString = "Fast" } ELSEIF ($LinkSpeedCalc -gt 45) { $LinkSpeedPerformanceRating = 5; $LinkSpeedPerformanceRatingString = "Good" } ELSEIF ($LinkSpeedCalc -gt 25) { $LinkSpeedPerformanceRating = 4; $LinkSpeedPerformanceRatingString = "Acceptable" } ELSEIF ($LinkSpeedCalc -gt 12) { $LinkSpeedPerformanceRating = 3; $LinkSpeedPerformanceRatingString = "Slow" } ELSEIF ($LinkSpeedCalc -gt 5) { $LinkSpeedPerformanceRating = 2; $LinkSpeedPerformanceRatingString = "Very Slow" } ELSE { $LinkSpeedPerformanceRating = 1; $LinkSpeedPerformanceRatingString = "Extremely Slow" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Network" PerformanceItem = $NetworkConnection.Type + " Link Speed" PerformanceResult = ($NetworkConnection.LinkSpeed.Split('\'))[0].ToString() + "/" + ($NetworkConnection.LinkSpeed.Split('\'))[1].ToString() + " Mbps" PerformanceRating = $LinkSpeedPerformanceRating PerformanceRatingString = $LinkSpeedPerformanceRatingString } } IF ($NetworkConnection.Status -eq "Disconnected") { #$Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ # PerformanceCategory = "Network" # PerformanceItem = $NetworkConnection.AdapterType + " Status" # PerformanceResult = "Disconnected" # PerformanceRating = $Blank # PerformanceRatingString = $Blank #} } } } } Write-Progress -ID 2 -Activity "Running Performance Tests" -Status "Running Internet SpeedTest - About 30 Seconds" -PercentComplete 70 IF ($Category -contains "Internet") { ### Internet Information $SpeedTestResults = Get-InternetSpeedTest IF ($null -eq $SpeedTestResults) { Write-Warning "SpeedTest.exe was blocked from running. Check security applications such as SentinelOne or ThreatLocker." $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Download Speed" PerformanceResult = "Unavailable" PerformanceRating = $Blank PerformanceRatingString = $Blank } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Download Latency" PerformanceResult = "Unavailable" PerformanceRating = $Blank PerformanceRatingString = $Blank } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Upload Speed" PerformanceResult = "Unavailable" PerformanceRating = $Blank PerformanceRatingString = $Blank } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Upload Latency" PerformanceResult = "Unavailable" PerformanceRating = $Blank PerformanceRatingString = $Blank } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Packet Loss" PerformanceResult = "Unavailable" PerformanceRating = $Blank PerformanceRatingString = $Blank } } ELSE { ### Download Speed IF ($True) { TRY { [int]$DownloadSpeed = $SpeedTestResults.DownloadSpeed.Replace(" Mbps","") IF ($DownloadSpeed -ge 800) { $DownloadSpeedPerformanceRating = 9; $DownloadSpeedPerformanceRatingString = "Crazy Fast" } ELSEIF ($DownloadSpeed -ge 400) { $DownloadSpeedPerformanceRating = 8; $DownloadSpeedPerformanceRatingString = "Extremely Fast" } ELSEIF ($DownloadSpeed -ge 200) { $DownloadSpeedPerformanceRating = 7; $DownloadSpeedPerformanceRatingString = "Very Fast" } ELSEIF ($DownloadSpeed -ge 100) { $DownloadSpeedPerformanceRating = 6; $DownloadSpeedPerformanceRatingString = "Fast" } ELSEIF ($DownloadSpeed -ge 65) { $DownloadSpeedPerformanceRating = 5; $DownloadSpeedPerformanceRatingString = "Good" } ELSEIF ($DownloadSpeed -ge 40) { $DownloadSpeedPerformanceRating = 4; $DownloadSpeedPerformanceRatingString = "Acceptable" } ELSEIF ($DownloadSpeed -ge 20) { $DownloadSpeedPerformanceRating = 3; $DownloadSpeedPerformanceRatingString = "Slow" } ELSEIF ($DownloadSpeed -ge 10) { $DownloadSpeedPerformanceRating = 2; $DownloadSpeedPerformanceRatingString = "Very Slow" } ELSE { $DownloadSpeedPerformanceRating = 1; $DownloadSpeedPerformanceRatingString = "Extremely Slow" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Download Speed" PerformanceResult = $DownloadSpeed.ToString() + " Mbps" PerformanceRating = $DownloadSpeedPerformanceRating PerformanceRatingString = $DownloadSpeedPerformanceRatingString } } CATCH { $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Download Speed" PerformanceResult = "[Test Error]" PerformanceRating = $Blank PerformanceRatingString = $Blank } } } ### Download Latency Avg IF ($True) { TRY { [int]$DownloadLatency = $SpeedTestResults.DownloadLatencyAvg.Replace(" ms","") IF ($DownloadLatency -le 20) { $DownloadLatencyPerformanceRating = 9; $DownloadLatencyPerformanceRatingString = "Crazy Fast" } ELSEIF ($DownloadLatency -le 40) { $DownloadLatencyPerformanceRating = 8; $DownloadLatencyPerformanceRatingString = "Extremely Fast" } ELSEIF ($DownloadLatency -le 80) { $DownloadLatencyPerformanceRating = 7; $DownloadLatencyPerformanceRatingString = "Very Fast" } ELSEIF ($DownloadLatency -le 125) { $DownloadLatencyPerformanceRating = 6; $DownloadLatencyPerformanceRatingString = "Fast" } ELSEIF ($DownloadLatency -le 200) { $DownloadLatencyPerformanceRating = 5; $DownloadLatencyPerformanceRatingString = "Good" } ELSEIF ($DownloadLatency -le 350) { $DownloadLatencyPerformanceRating = 4; $DownloadLatencyPerformanceRatingString = "Acceptable" } ELSEIF ($DownloadLatency -le 750) { $DownloadLatencyPerformanceRating = 3; $DownloadLatencyPerformanceRatingString = "Slow" } ELSEIF ($DownloadLatency -le 1250) { $DownloadLatencyPerformanceRating = 2; $DownloadLatencyPerformanceRatingString = "Very Slow" } ELSE { $DownloadLatencyPerformanceRating = 1; $DownloadLatencyPerformanceRatingString = "Extremely Slow" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Download Latency (Avg)" PerformanceResult = $DownloadLatency.ToString() + " ms" PerformanceRating = $DownloadLatencyPerformanceRating PerformanceRatingString = $DownloadLatencyPerformanceRatingString } } CATCH { $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Download Latency (Avg)" PerformanceResult = "[Test Error]" PerformanceRating = $Blank PerformanceRatingString = $Blank } } } ### Download Latency High IF ($true) { TRY { [int]$DownloadLatencyHigh = $SpeedTestResults.DownloadLatencyHigh.Replace(" ms","") IF ($DownloadLatencyHigh -le 40) { $DownloadLatencyHighRating = 9; $DownloadLatencyHighRatingString = "Crazy Fast" } ELSEIF ($DownloadLatencyHigh -le 80) { $DownloadLatencyHighRating = 8; $DownloadLatencyHighRatingString = "Extremely Fast" } ELSEIF ($DownloadLatencyHigh -le 160) { $DownloadLatencyHighRating = 7; $DownloadLatencyHighRatingString = "Very Fast" } ELSEIF ($DownloadLatencyHigh -le 250) { $DownloadLatencyHighRating = 6; $DownloadLatencyHighRatingString = "Fast" } ELSEIF ($DownloadLatencyHigh -le 400) { $DownloadLatencyHighRating = 5; $DownloadLatencyHighRatingString = "Good" } ELSEIF ($DownloadLatencyHigh -le 700) { $DownloadLatencyHighRating = 4; $DownloadLatencyHighRatingString = "Acceptable" } ELSEIF ($DownloadLatencyHigh -le 1500) { $DownloadLatencyHighRating = 3; $DownloadLatencyHighRatingString = "Slow" } ELSEIF ($DownloadLatencyHigh -le 2500) { $DownloadLatencyHighRating = 2; $DownloadLatencyHighRatingString = "Very Slow" } ELSE { $DownloadLatencyHighRating = 1; $DownloadLatencyHighRatingString = "Extremely Slow" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Download Latency (High)" PerformanceResult = $DownloadLatencyHigh.ToString() + " ms" PerformanceRating = $DownloadLatencyHighRating PerformanceRatingString = $DownloadLatencyHighRatingString } } CATCH { $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Download Latency (High)" PerformanceResult = "[Test Error]" PerformanceRating = $Blank PerformanceRatingString = $Blank } } } ### Upload Speed IF ($True) { TRY { [int]$UploadSpeed = $SpeedTestResults.UploadSpeed.Replace(" Mbps","") IF ($UploadSpeed -ge 200) { $UploadSpeedPerformanceRating = 9; $UploadSpeedPerformanceRatingString = "Crazy Fast" } ELSEIF ($UploadSpeed -ge 100) { $UploadSpeedPerformanceRating = 8; $UploadSpeedPerformanceRatingString = "Extremely Fast" } ELSEIF ($UploadSpeed -ge 50) { $UploadSpeedPerformanceRating = 7; $UploadSpeedPerformanceRatingString = "Very Fast" } ELSEIF ($UploadSpeed -ge 25) { $UploadSpeedPerformanceRating = 6; $UploadSpeedPerformanceRatingString = "Fast" } ELSEIF ($UploadSpeed -ge 18) { $UploadSpeedPerformanceRating = 5; $UploadSpeedPerformanceRatingString = "Good" } ELSEIF ($UploadSpeed -ge 12) { $UploadSpeedPerformanceRating = 4; $UploadSpeedPerformanceRatingString = "Acceptable" } ELSEIF ($UploadSpeed -ge 8) { $UploadSpeedPerformanceRating = 3; $UploadSpeedPerformanceRatingString = "Slow" } ELSEIF ($UploadSpeed -ge 4) { $UploadSpeedPerformanceRating = 2; $UploadSpeedPerformanceRatingString = "Very Slow" } ELSE { $UploadSpeedPerformanceRating = 1; $UploadSpeedPerformanceRatingString = "Extremely Slow" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Upload Speed" PerformanceResult = $UploadSpeed.ToString() + " Mbps" PerformanceRating = $UploadSpeedPerformanceRating PerformanceRatingString = $UploadSpeedPerformanceRatingString } } CATCH { $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Upload Speed" PerformanceResult = "[Test Error]" PerformanceRating = $Blank PerformanceRatingString = $Blank } } } ### Upload Latency Avg IF ($True) { TRY { [int]$UploadLatency = $SpeedTestResults.UploadLatencyAvg.Replace(" ms","") IF ($UploadLatency -le 20) { $UploadLatencyPerformanceRating = 9; $UploadLatencyPerformanceRatingString = "Crazy Fast" } ELSEIF ($UploadLatency -le 40) { $UploadLatencyPerformanceRating = 8; $UploadLatencyPerformanceRatingString = "Extremely Fast" } ELSEIF ($UploadLatency -le 80) { $UploadLatencyPerformanceRating = 7; $UploadLatencyPerformanceRatingString = "Very Fast" } ELSEIF ($UploadLatency -le 125) { $UploadLatencyPerformanceRating = 6; $UploadLatencyPerformanceRatingString = "Fast" } ELSEIF ($UploadLatency -le 200) { $UploadLatencyPerformanceRating = 5; $UploadLatencyPerformanceRatingString = "Good" } ELSEIF ($UploadLatency -le 350) { $UploadLatencyPerformanceRating = 4; $UploadLatencyPerformanceRatingString = "Acceptable" } ELSEIF ($UploadLatency -le 750) { $UploadLatencyPerformanceRating = 3; $UploadLatencyPerformanceRatingString = "Slow" } ELSEIF ($UploadLatency -le 1250) { $UploadLatencyPerformanceRating = 2; $UploadLatencyPerformanceRatingString = "Very Slow" } ELSE { $UploadLatencyPerformanceRating = 1; $UploadLatencyPerformanceRatingString = "Extremely Slow" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Upload Latency (Avg)" PerformanceResult = $UploadLatency.ToString() + " ms" PerformanceRating = $UploadLatencyPerformanceRating PerformanceRatingString = $UploadLatencyPerformanceRatingString } } CATCH { $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Upload Latency (Avg)" PerformanceResult = "[Test Error]" PerformanceRating = $Blank PerformanceRatingString = $Blank } } } ### Upload Latency High IF ($true) { TRY { [int]$UploadLatencyHigh = $SpeedTestResults.UploadLatencyHigh.Replace(" ms","") IF ($UploadLatencyHigh -le 40) { $UploadLatencyHighPerformanceRating = 9; $UploadLatencyHighPerformanceRatingString = "Crazy Fast" } ELSEIF ($UploadLatencyHigh -le 80) { $UploadLatencyHighPerformanceRating = 8; $UploadLatencyHighPerformanceRatingString = "Extremely Fast" } ELSEIF ($UploadLatencyHigh -le 160) { $UploadLatencyHighPerformanceRating = 7; $UploadLatencyHighPerformanceRatingString = "Very Fast" } ELSEIF ($UploadLatencyHigh -le 250) { $UploadLatencyHighPerformanceRating = 6; $UploadLatencyHighPerformanceRatingString = "Fast" } ELSEIF ($UploadLatencyHigh -le 400) { $UploadLatencyHighPerformanceRating = 5; $UploadLatencyHighPerformanceRatingString = "Good" } ELSEIF ($UploadLatencyHigh -le 700) { $UploadLatencyHighPerformanceRating = 4; $UploadLatencyHighPerformanceRatingString = "Acceptable" } ELSEIF ($UploadLatencyHigh -le 1500) { $UploadLatencyHighPerformanceRating = 3; $UploadLatencyHighPerformanceRatingString = "Slow" } ELSEIF ($UploadLatencyHigh -le 2500) { $UploadLatencyHighPerformanceRating = 2; $UploadLatencyHighPerformanceRatingString = "Very Slow" } ELSE { $UploadLatencyHighPerformanceRating = 1; $UploadLatencyHighPerformanceRatingString = "Extremely Slow" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Upload Latency (High)" PerformanceResult = $UploadLatencyHigh.ToString() + " ms" PerformanceRating = $UploadLatencyHighPerformanceRating PerformanceRatingString = $UploadLatencyHighPerformanceRatingString } } CATCH { $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Upload Latency (High)" PerformanceResult = "[Test Error]" PerformanceRating = $Blank PerformanceRatingString = $Blank } } } ### Packet Loss IF ($True) { TRY { [int]$PacketLoss = $SpeedTestResults.PacketLoss.Replace("%","") IF ($PacketLoss -eq 0) { $PacketLossPerformanceRating = 9; $PacketLossPerformanceRatingString = "Perfect" } ELSEIF ($PacketLoss -le 1) { $PacketLossPerformanceRating = 8; $PacketLossPerformanceRatingString = "Extremely Low" } ELSEIF ($PacketLoss -le 2) { $PacketLossPerformanceRating = 7; $PacketLossPerformanceRatingString = "Very Low" } ELSEIF ($PacketLoss -le 3) { $PacketLossPerformanceRating = 6; $PacketLossPerformanceRatingString = "Low" } ELSEIF ($PacketLoss -le 4) { $PacketLossPerformanceRating = 5; $PacketLossPerformanceRatingString = "Good" } ELSEIF ($PacketLoss -le 5) { $PacketLossPerformanceRating = 4; $PacketLossPerformanceRatingString = "Acceptable" } ELSEIF ($PacketLoss -le 7) { $PacketLossPerformanceRating = 3; $PacketLossPerformanceRatingString = "High" } ELSEIF ($PacketLoss -le 10) { $PacketLossPerformanceRating = 2; $PacketLossPerformanceRatingString = "Very High" } ELSE { $PacketLossPerformanceRating = 1; $PacketLossPerformanceRatingString = "Extremely High" } IF ($PacketLoss -ge 0) { [string]$PacketLoss = $PacketLoss.ToString() + "%" } ELSE { [string]$PacketLoss = "Unavailable"; $PacketLossPerformanceRating = ""; $PacketLossPerformanceRatingString = "" } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Packet Loss" PerformanceResult = $PacketLoss PerformanceRating = $PacketLossPerformanceRating PerformanceRatingString = $PacketLossPerformanceRatingString } } CATCH { $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PerformanceCategory = "Internet" PerformanceItem = "Packet Loss" PerformanceResult = "[Test Error]" PerformanceRating = $Blank PerformanceRatingString = $Blank } } } } } Write-Progress -ID 2 -Activity "Running Performance Tests" -Completed IF ($PSVersionTable.PSVersion.Major -ge 7) { RETURN $Results | Select-Object PerformanceCategory, PerformanceItem, PerformanceResult, PerformanceRating, PerformanceRatingString | Sort-Object -Property PerformanceRating -Descending | Format-Table | Out-String -Stream | ForEach-Object { IF ($_ -like "*CPU Score*" -and $_ -like "*Extremely Slow*") {"$($PSStyle.Foreground.FromRgb(225,0,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*CPU Score*" -and $_ -like "*Very Slow*") {"$($PSStyle.Foreground.FromRgb(200,100,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*CPU Score*" -and $_ -like "*Slow*") {"$($PSStyle.Foreground.FromRgb(200,200,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*CPU Age*" -and $_ -like "*Extremely Old*") {"$($PSStyle.Foreground.FromRgb(200,100,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*CPU Age*" -and $_ -like "*Very Old*") {"$($PSStyle.Foreground.FromRgb(200,200,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*RAM Total*" -and $_ -like "*Extremely Low*") {"$($PSStyle.Foreground.FromRgb(225,0,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*RAM Total*" -and $_ -like "*Very Low*") {"$($PSStyle.Foreground.FromRgb(200,100,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*RAM Total*" -and $_ -like "*Low*") {"$($PSStyle.Foreground.FromRgb(200,200,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*Disk*" -and $_ -like "*Extremely Slow*") {"$($PSStyle.Foreground.FromRgb(225,0,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*Disk*" -and $_ -like "*Very Slow*") {"$($PSStyle.Foreground.FromRgb(200,100,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*Disk*" -and $_ -like "*Slow*") {"$($PSStyle.Foreground.FromRgb(200,200,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*Network*" -and $_ -like "*Extremely Slow*") {"$($PSStyle.Foreground.FromRgb(225,0,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*Network*" -and $_ -like "*Very Slow*") {"$($PSStyle.Foreground.FromRgb(200,100,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*Network*" -and $_ -like "*Slow*") {"$($PSStyle.Foreground.FromRgb(200,200,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*Packet Loss*" -and $_ -like "*Extremely High*") {"$($PSStyle.Foreground.FromRgb(225,0,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*Packet Loss*" -and $_ -like "*Very High*") {"$($PSStyle.Foreground.FromRgb(200,100,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*Packet Loss*" -and $_ -like "*High*") {"$($PSStyle.Foreground.FromRgb(200,200,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*Internet*" -and $_ -like "*Extremely Slow*") {"$($PSStyle.Foreground.FromRgb(225,0,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*Internet*" -and $_ -like "*Very Slow*") {"$($PSStyle.Foreground.FromRgb(200,100,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -like "*Internet*" -and $_ -like "*Slow*") {"$($PSStyle.Foreground.FromRgb(200,200,0))$_$($PSStyle.Reset)" } ELSE {"$($PSStyle.Foreground.FromRgb(255,255,255))$_$($PSStyle.Reset)" } } } ELSE { RETURN $Results | Select-Object PerformanceCategory, PerformanceItem, PerformanceResult, PerformanceRating, PerformanceRatingString | Sort-Object -Property PerformanceRating -Descending | Format-Table | Out-String -Stream | ForEach-Object { $OutA = IF ($_ -like "*CPU Score*" -and $_ -like "*Extremely Slow*") {@{'ForegroundColor' = 'Red' }} ELSEIF ($_ -like "*CPU Score*" -and $_ -like "*Very Slow*") {@{'ForegroundColor' = 'Magenta' }} ELSEIF ($_ -like "*CPU Score*" -and $_ -like "*Slow*") {@{'ForegroundColor' = 'Yellow' }} ELSEIF ($_ -like "*CPU Age*" -and $_ -like "*Extremely Old*") {@{'ForegroundColor' = 'Magenta' }} ELSEIF ($_ -like "*CPU Age*" -and $_ -like "*Very Old*") {@{'ForegroundColor' = 'Yellow' }} ELSEIF ($_ -like "*RAM Total*" -and $_ -like "*Extremely Low*") {@{'ForegroundColor' = 'Red' }} ELSEIF ($_ -like "*RAM Total*" -and $_ -like "*Very Low*") {@{'ForegroundColor' = 'Magenta' }} ELSEIF ($_ -like "*RAM Total*" -and $_ -like "*Low*") {@{'ForegroundColor' = 'Yellow' }} ELSEIF ($_ -like "*Disk*" -and $_ -like "*Extremely Slow*") {@{'ForegroundColor' = 'Red' }} ELSEIF ($_ -like "*Disk*" -and $_ -like "*Very Slow*") {@{'ForegroundColor' = 'Magenta' }} ELSEIF ($_ -like "*Disk*" -and $_ -like "*Slow*") {@{'ForegroundColor' = 'Yellow' }} ELSEIF ($_ -like "*Network*" -and $_ -like "*Extremely Slow*") {@{'ForegroundColor' = 'Red' }} ELSEIF ($_ -like "*Network*" -and $_ -like "*Very Slow*") {@{'ForegroundColor' = 'Magenta' }} ELSEIF ($_ -like "*Network*" -and $_ -like "*Slow*") {@{'ForegroundColor' = 'Yellow' }} ELSEIF ($_ -like "*Packet Loss*" -and $_ -like "*Extremely High*") {@{'ForegroundColor' = 'Red' }} ELSEIF ($_ -like "*Packet Loss*" -and $_ -like "*Very High*") {@{'ForegroundColor' = 'Magenta' }} ELSEIF ($_ -like "*Packet Loss*" -and $_ -like "*High*") {@{'ForegroundColor' = 'Yellow' }} ELSEIF ($_ -like "*Internet*" -and $_ -like "*Extremely Slow*") {@{'ForegroundColor' = 'Red' }} ELSEIF ($_ -like "*Internet*" -and $_ -like "*Very Slow*") {@{'ForegroundColor' = 'Magenta' }} ELSEIF ($_ -like "*Internet*" -and $_ -like "*Slow*") {@{'ForegroundColor' = 'Yellow' }} ELSE {@{'ForegroundColor' = 'White' }} Write-Host @OutA $_ } } } New-Alias -Name Diagnose-ComputerPerformance -Value Debug-ComputerPerformance New-Alias -Name Debug-PCPerformance -Value Debug-ComputerPerformance New-Alias -Name Diagnose-PCPerformance -Value Debug-ComputerPerformance New-Alias -Name Report-ComputerPerformance -Value Debug-ComputerPerformance New-Alias -Name Report-PCPerformance -Value Debug-ComputerPerformance |