Public/Diagnostics/Debug-Computer.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Debug-Computer { <# .SYNOPSIS This function performs various diagnostic tests on a computer. .DESCRIPTION The function runs a series of diagnostic tests, including internet speed, disk performance, and network connection checks. It collects and processes information about the computer's hardware, operating system, and network configuration to identify potential issues. .PARAMETER InternetSpeedTest Runs an internet speed test if specified. .PARAMETER DiskSpeedTest Runs a disk performance test if specified. .PARAMETER IssuesOnly Displays only the issues found if specified. .PARAMETER Full Runs a full diagnostic test, including internet speed and disk performance tests. .EXAMPLE PS C:\> Debug-Computer -Full Runs a full diagnostic test on the computer, including internet speed and disk performance tests. #> PARAM ( [SWITCH]$InternetSpeedTest = $False, [SWITCH]$DiskSpeedTest = $False, [SWITCH]$IssuesOnly = $False, [SWITCH]$Full = $False ) IF (!(Test-AdministratorElevation)) { Write-Warning "This command must be run with administrator elevation. Please elevate and try again."; RETURN } FUNCTION AddResults { Param( [string]$Category = $null, [string]$Item = $null, [string]$ItemDetails = $null, [string]$Result = $null, [string]$AlertLevel = $null, [string]$ResultDetails = $null ) IF ($AlertLevel -eq "Normal" -and $IssuesOnly -eq $True) { RETURN $Null } $Output += New-Object PSObject -WarningAction SilentlyContinue -Property @{ Category = $Category Item = $Item ItemDetails = $ItemDetails Result = $Result AlertLevel = $AlertLevel ResultDetails = $ResultDetails } RETURN $Output } FUNCTION UpdateProgressBar { Param ( [string]$Action = $null ) $ProgressPercent = [math]::round(($ProgressCountCurrent / $ProgressCountTotal) * 100,0) Write-Progress -ID 13 -Activity "Checking All" -Status "$ProgressPercent% - $Action" -PercentComplete $ProgressPercent } ### Scan Profiles IF ($Full -eq $True) { $ScanIPTypes = @("IPv4") $ScanDNSTestCount = 15 $InternetSpeedTest = $True $DiskSpeedTest = $True $ScanAdapterTypes = @("WiFi","Wired","VPN","Hyper-V","Bluetooth") } ELSE { $ScanIPTypes = @("IPv4") $ScanDNSTestCount = 5 $ScanAdapterTypes = @("WiFi","Wired","VPN") } ### Calculate Progress Count $ProgressCountCurrent = 0 $ProgressCountTotal = 38 IF ($InternetSpeedTest -eq $True) { $ProgressCountTotal += 25 } IF ($DiskSpeedTest -eq $True) { $ProgressCountTotal += 58 } IF ($ScanIPTypes -contains "IPv6") { $ProgressCountTotal += 2.66 } IF ($ScanDNSTestCount -eq 15) { $ProgressCountTotal += 5.32 } $Results = @() $NetworkAdaptersChecked = @() $NetworkConnections = @() $NetworkAdaptersChecked | Out-Null $ScanAdapterTypes | Out-Null ### Global Variables $NoIssuesFound = "" ### Collect Info UpdateProgressBar -Action "Running Internet Speed Test" IF ($InternetSpeedTest -eq $True) { $InternetSpeedTestResults = Get-InternetSpeedTest; $ProgressCountCurrent += 25 } UpdateProgressBar -Action "Running Disk Speed Test" IF ($DiskSpeedTest -eq $True) { $DiskSpeedTestResults = Get-DiskPerformance; $ProgressCountCurrent += 58 } UpdateProgressBar -Action "Getting Current Date" $Now = Get-Date; $ProgressCountCurrent += 0 UpdateProgressBar -Action "Getting Crash Events" $BSODEvents = Get-WindowsCrashEvent -Days 60 -EventType BSOD; $ProgressCountCurrent += 0.25 $PowerLossEvents = Get-WindowsCrashEvent -Days 60 -EventType PowerLoss; $ProgressCountCurrent += 0.25 UpdateProgressBar -Action "Getting OS Information" $OSInfo = Get-WindowsInfo; $ProgressCountCurrent += 2.5 $OSShortName = Get-OSShortName $IsWorkstation = Test-IsWorkstation $IsServer = Test-IsServer $IsADJoined = Test-IsADJoined $IsLaptop = Test-IsLaptop UpdateProgressBar -Action "Getting Domain Information" $DomainInfo = Get-DomainInfo; $ProgressCountCurrent += .25 UpdateProgressBar -Action "Getting Chassis Information" $ChassisInfo = Get-ChassisInfo; $ProgressCountCurrent += 3 UpdateProgressBar -Action "Getting Time Information" $TimeInfo = Get-TimeInfo -NoTimeZone; $ProgressCountCurrent += 4.71 UpdateProgressBar -Action "Getting Volume Information" $SystemVolume = Get-VolumeSystem; $ProgressCountCurrent += 3 $OSDriveType = (Get-PhysicalDisk -DeviceNumber (Get-Partition -DriveLetter (($env:windir).Substring(0,1))).DiskNumber).MediaType UpdateProgressBar -Action "Getting Network Connection Information" $NetworkConnections = Get-NetworkAdapter -AdapterType All; $ProgressCountCurrent += 9.25 UpdateProgressBar -Action "Getting VPN Connections" $VPNConnections = Get-VPNAdapter; $ProgressCountCurrent += .25 UpdateProgressBar -Action "Testing External DNS" $ExternalDNS = Test-DNSResolution -Name Google.com,Microsoft.com -TestCount $ScanDNSTestCount; IF ($ScanDNSTestCount -eq 5) { $ProgressCountCurrent += 1.33} ELSE { $ProgressCountCurrent += 4 } UpdateProgressBar -Action "Getting DNS Suffix Information" $GlobalDNSSuffixes = (Get-DNSClientGlobalSetting).SuffixSearchList $TempCount = 0 FOREACH ($Item in $GlobalDNSSuffixes) { $GlobalDNSSuffixes[$TempCount] = "[$Item]"; $TempCount++ } $DNSSuffixSearchList = (Get-DNSClientGlobalSetting).SuffixSearchList; $ProgressCountCurrent += .33 FOREACH ($VPNConnection in $VPNConnections) { FOREACH ($Suffix in $VPNConnection.DNSSuffix) { IF ($DNSSuffixSearchList -notcontains $Suffix -and $Suffix -ne "") { $DNSSuffixSearchList += $Suffix } } } FOREACH ($NetworkConnection in $NetworkConnections) { IF ($NetworkConnection.Status -eq "Disconnected") { continue } FOREACH ($Suffix in $NetworkConnection.DNSSuffix) { IF ($DNSSuffixSearchList -notcontains $Suffix -and $Suffix -ne "") { $DNSSuffixSearchList += $Suffix } } } UpdateProgressBar -Action "Testing Internal DNS" IF ($DNSSuffixSearchList.Count -eq 0) { $InternalDNS = $Null } ELSE { $InternalDNS = Test-DNSResolution -Name $DNSSuffixSearchList -TestCount $ScanDNSTestCount }; IF ($ScanDNSTestCount -eq 5) { $ProgressCountCurrent += 1.33} ELSE { $ProgressCountCurrent += 4 } UpdateProgressBar -Action "Getting CPU Information" $CPUs = Get-CPUDevice; $ProgressCountCurrent += 2.70 UpdateProgressBar -Action "Getting RAM Information" $AvailableMemoryGBs = [math]::round((Get-CIMInstance Win32_OperatingSystem).FreePhysicalMemory / 1MB,2); $ProgressCountCurrent += 0 UpdateProgressBar -Action "Getting PageFile Information" $PageFileSize = [math]::round((Get-CIMInstance Win32_PagefileUsage).AllocatedBaseSize / 1KB,2); $ProgressCountCurrent += 0 UpdateProgressBar -Action "Getting Internet Information" $InternetInfo = Get-InternetInfo; $ProgressCountCurrent += .35 UpdateProgressBar -Action "Getting WinRE Info" IF ($IsServer) {} ELSE { $WinRE = Get-WinRE }; $ProgressCountCurrent += 5 UpdateProgressBar -Action "Getting TPM Info" $TPM = Get-TPM; $ProgressCountCurrent += 0 UpdateProgressBar -Action "Getting Cryptography Protocol Info" $CryptoProtocols = Get-CryptoProtocol; $ProgressCountCurrent += 0 UpdateProgressBar -Action "Getting Automate Agent Info" $AutomateAgentInfo = Get-AutomateAgentInfo; $ProgressCountCurrent += 0 UpdateProgressBar -Action "Getting Notable Applications" $ApplicationNotable = Get-ApplicationNotable; $ProgressCountCurrent += 1.5 ######################################### ####### Operating System Category ####### ######################################### ### Windows Type Home/Pro Enterprise IF ($True) { IF ($OSInfo.Name -like "*Home*") { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Type" -Result $OSInfo.OSName -AlertLevel "Critical" -ResultDetails "Workstation Computers Should be Windows Pro or Enterprise" } ELSE { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Type" -Result $OSInfo.OSName -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### Windows Build IF ($True) { IF ($OSInfo.OSName -like "*Windows 10*") { IF ($OSInfo.BuildNumber -eq 19045) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Build Number" -Result $OSInfo.BuildNumber -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Build Number" -Result $OSInfo.BuildNumber -AlertLevel "Warning" -ResultDetails "OS Build is End of Life" } } ELSEIF ($OSInfo.OSName -like "*Windows 11*") { IF ([int]$OSInfo.BuildNumber -ge 22621) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Build Number" -Result $OSInfo.BuildNumber -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Build Number" -Result $OSInfo.BuildNumber -AlertLevel "Warning" -ResultDetails "OS Build is End of Life" } } ELSE { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Build Number" -Result $OSInfo.BuildNumber -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### Windows Crashes IF ($True) { IF ($BSODEvents.Count -eq 0) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Recent BSOD Events" -Result "$($BSODEvents.Count) Events" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($BSODEvents.Count -eq 2) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Recent BSOD Events" -Result "$($BSODEvents.Count) Events" -AlertLevel "Warning" -ResultDetails "$($BSODEvents.Count) BSOD Events Within Last 60 Days" } ELSEIF ($BSODEvents.Count -eq 3) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Recent BSOD Events" -Result "$($BSODEvents.Count) Events" -AlertLevel "Error" -ResultDetails "$($BSODEvents.Count) BSOD Events Within Last 60 Days" } ELSEIF ($BSODEvents.Count -gt 3) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Recent BSOD Events" -Result "$($BSODEvents.Count) Events" -AlertLevel "Warning" -ResultDetails "$($BSODEvents.Count) BSOD Events Within Last 60 Days" } ELSE { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Recent BSOD Events" -Result "1 Event" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } IF ($True) { IF ($PowerLossEvents.Count -eq 0) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Recent Power Loss Events" -Result "$($PowerLossEvents.Count) Events" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($PowerLossEvents.Count -eq 2) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Recent Power Loss Events" -Result "$($PowerLossEvents.Count) Events" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($PowerLossEvents.Count -eq 3) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Recent Power Loss Events" -Result "$($PowerLossEvents.Count) Events" -AlertLevel "Warning" -ResultDetails "$($PowerLossEvents.Count) Power Loss Events Within Last 60 Days" } ELSEIF ($PowerLossEvents.Count -eq 4) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Recent Power Loss Events" -Result "$($PowerLossEvents.Count) Events" -AlertLevel "Error" -ResultDetails "$($PowerLossEvents.Count) Power Loss Events Within Last 60 Days" } ELSEIF ($PowerLossEvents.Count -gt 4) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Recent Power Loss Events" -Result "$($PowerLossEvents.Count) Events" -AlertLevel "Warning" -ResultDetails "$($PowerLossEvents.Count) Power Loss Events Within Last 60 Days" } ELSE { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Recent Power Loss Events" -Result "1 Event" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### Page File Size IF ($True) { IF ($PageFileSize -gt 12) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Page File Size" -Result ($PageFileSize.ToString() + " GBs") -AlertLevel "Critical" -ResultDetails "Extremely Large Page File" } ELSEIF ($PageFileSize -gt 8) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Page File Size" -Result ($PageFileSize.ToString() + " GBs") -AlertLevel "Error" -ResultDetails "Very Large Page File" } ELSEIF ($PageFileSize -gt 4.5) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Page File Size" -Result ($PageFileSize.ToString() + " GBs") -AlertLevel "Warning" -ResultDetails "Large Page File" } ELSE { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Page File Size" -Result ($PageFileSize.ToString() + " GBs") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### Days Since Last Reboot IF ($True) { $LastRebootTimeSpan = $Now - $OSInfo.LastBootTime IF ($LastRebootTimeSpan.TotalDays -gt 40) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Days Since Last Reboot" -Result (([math]::round($($LastRebootTimeSpan.TotalDays),0)).ToString() + " Days") -AlertLevel "Error" -ResultDetails ([math]::round($LastRebootTimeSpan.TotalDays,0).ToString() + " Days Since Last Reboot") } ELSEIF ($LastRebootTimeSpan.TotalDays -gt 20) { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Days Since Last Reboot" -Result (([math]::round($($LastRebootTimeSpan.TotalDays),0)).ToString() + " Days") -AlertLevel "Warning" -ResultDetails ([math]::round($LastRebootTimeSpan.TotalDays,0).ToString() + " Days Since Last Reboot") } ELSE { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Days Since Last Reboot" -Result (([math]::round($($LastRebootTimeSpan.TotalDays),0)).ToString() + " Days") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### WinRE Status IF ($True) { IF ($IsServer) {} ELSEIF ($WinRE.WinREStatus -eq "Enabled") { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "WinRE" -Result $WinRE.WinREStatus -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "WinRE Status" -Result $WinRE.WinREStatus -AlertLevel "Warning" -ResultDetails "WinRE is Disabled" } } ### PowerMode Status IF ($True) { IF ($IsLaptop) { IF ($OSInfo.PowerMode -eq "Best Performance") { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Power Mode" -Result $OSInfo.PowerMode -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "Operating System" -Item $OSShortName -ItemDetails "Power Mode" -Result $OSInfo.PowerMode -AlertLevel "Warning" -ResultDetails "Power Mode Not Set to Best Performance" } } } ############################################# ####### Automate Information Category ####### ############################################# ### Last Checkin IF ($True) { [DateTime]$LastCheckIn = "1/1/1" $LastCheckInTimeSpan = $null Try { [DateTime]$LastCheckIn = $AutomateAgentInfo.LastCheckIn } CATCH { } Try { $LastCheckInTimeSpan = (Get-Date) - $LastCheckIn } CATCH { } IF ($LastCheckInTimeSpan.TotalDays -le 1 -and $LastCheckInTimeSpan.TotalDays -ge 0) { $Results += AddResults -Category "Automate" -Item "Status" -ItemDetails "Last Check-In" -Result $LastCheckIn -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($LastCheckInTimeSpan.TotalDays -le 999 -and $LastCheckInTimeSpan.TotalDays -ge 0) { $Results += AddResults -Category "Automate" -Item "Status" -ItemDetails "Last Check-In" -Result $LastCheckIn -AlertLevel "Warning" -ResultDetails "Check-In More than 1 Day Ago" } ELSE { $Results += AddResults -Category "Automate" -Item "Status" -ItemDetails "Last Check-In" -Result $LastCheckIn -AlertLevel "Error" -ResultDetails "Agent Never Checked-In" } } ### LTSVC Address IF ($True) { IF ($null -ne $AutomateAgentInfo.ServerAddress -and "" -ne $AutomateAgentInfo.ServerAddress) { $AutomateServers = $AutomateAgentInfo.ServerAddress -split '\|' $Results += AddResults -Category "Automate" -Item "Server Address" -ItemDetails "Is Present" -Result $AutomateServers -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "Automate" -Item "Server Address" -ItemDetails "Is Present" -Result $null -AlertLevel "Error" -ResultDetails "Server Address Missing" } } ### Client ID IF ($True) { IF ($null -ne $AutomateAgentInfo.ClientID -and "" -ne $AutomateAgentInfo.ClientID) { $Results += AddResults -Category "Automate" -Item "Device Info" -ItemDetails "Client ID" -Result $AutomateAgentInfo.ClientID -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "Automate" -Item "Device Info" -ItemDetails "Client ID" -Result $null -AlertLevel "Error" -ResultDetails "Client ID Missing" } } ### Location ID IF ($True) { IF ($null -ne $AutomateAgentInfo.LocationID -and "" -ne $AutomateAgentInfo.LocationID) { $Results += AddResults -Category "Automate" -Item "Device Info" -ItemDetails "Location ID" -Result $AutomateAgentInfo.LocationID -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "Automate" -Item "Device Info" -ItemDetails "Location ID" -Result $null -AlertLevel "Error" -ResultDetails "Location ID Missing" } } ### Device ID IF ($True) { IF ($null -ne $AutomateAgentInfo.DeviceID -and "" -ne $AutomateAgentInfo.DeviceID) { $Results += AddResults -Category "Automate" -Item "Device Info" -ItemDetails "Device ID" -Result $AutomateAgentInfo.DeviceID -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "Automate" -Item "Device Info" -ItemDetails "Device ID" -Result $null -AlertLevel "Error" -ResultDetails "Device ID Missing" } } ### LTSvc Service IF ($True) { $LTSvc = $null $LTSvc = (Get-CimInstance win32_service -ErrorAction SilentlyContinue | Where-Object { $_.PathName -like "*\ltsvc.exe*" }) IF ($LTSvc) { IF ($LTSVC.State -eq "Running") { $Results += AddResults -Category "Automate" -Item "LTSvc Process" -ItemDetails "Is Running" -Result $True -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "Automate" -Item "LTSvc Process" -ItemDetails "Is Running" -Result $False -AlertLevel "Error" -ResultDetails "LTSvc Service Not Running" } } ELSE { $Results += AddResults -Category "Automate" -Item "LTSvc Process" -ItemDetails "Is Running" -Result $False -AlertLevel "Error" -ResultDetails "LTSvc Service Not Found" } } ### LTSvcMon Service IF ($True) { $LTSvcMon = $null $LTSvcMon = (Get-CimInstance win32_service -ErrorAction SilentlyContinue | Where-Object { $_.PathName -like "*\ltsvcmon.exe*" }) IF ($LTSvcMon) { IF ($LTSvcMon.State -eq "Running") { $Results += AddResults -Category "Automate" -Item "LTSvcMon Process" -ItemDetails "Is Running" -Result $True -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "Automate" -Item "LTSvcMon Process" -ItemDetails "Is Running" -Result $False -AlertLevel "Error" -ResultDetails "LTSvcMon Service Not Running" } } ELSE { $Results += AddResults -Category "Automate" -Item "LTSvcMon Process" -ItemDetails "Is Running" -Result $False -AlertLevel "Error" -ResultDetails "LTSvcMon Service Not Found" } } ########################################### ####### Domain Information Category ####### ########################################### ### Domain Join Type IF ($True) { IF ($DomainInfo.DomainType -eq "AD") { ### Domain Type $Results += AddResults -Category "Domain" -Item $DomainInfo.FQDN -ItemDetails "Domain Type" -Result $Domaininfo.DomainType -AlertLevel "Normal" -ResultDetails "$NoIssuesFound" ### Domain Join Health IF (Test-IsDomainController) { $Results += AddResults -Category "Domain" -Item $DomainInfo.FQDN -ItemDetails "Domain Health" -Result "Is Domain Controller" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($DomainInfo.DomainJoinHealth -eq "Unhealthy") { $Results += AddResults -Category "Domain" -Item $DomainInfo.FQDN -ItemDetails "Domain Health" -Result $Domaininfo.DomainJoinHealth -AlertLevel "Warning" -ResultDetails "Domain Rejoin Needed" } ELSE { $Results += AddResults -Category "Domain" -Item $DomainInfo.FQDN -ItemDetails "Domain Health" -Result $Domaininfo.DomainJoinHealth -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ELSEIF ($DomainInfo.DomainType -eq "AAD") { ### Domain Type $Results += AddResults -Category "Domain" -Item $DomainInfo.TenantName -ItemDetails "Domain Type" -Result $Domaininfo.DomainType -AlertLevel "Normal" -ResultDetails "$NoIssuesFound" ### Domain Join Health IF ($DomainInfo.DomainJoinHealth -eq "Unhealthy") { $Results += AddResults -Category "Domain" -Item $DomainInfo.FQDN -ItemDetails "Domain Health" -Result $Domaininfo.DomainJoinHealth -AlertLevel "Warning" -ResultDetails "Domain Rejoin Needed" } ELSE { $Results += AddResults -Category "Domain" -Item $DomainInfo.TenantName -ItemDetails "Domain Health" -Result $Domaininfo.DomainJoinHealth -AlertLevel "Normal" -ResultDetails "$NoIssuesFound" } } ELSE{ $Results += AddResults -Category "Domain" -Item "Workgroup" -ItemDetails "Domain Type" -Result $Domaininfo.DomainType -AlertLevel "Warning" -ResultDetails "Computer Not Domain Joined" } } ########################################## ####### Time and Location Category ####### ########################################## ### Check Time Seconds Off IF ($True) { IF ($TimeInfo.SecondsDifference -gt 300) { $Results += AddResults -Category "Time & Locale" -Item "System Time" -ItemDetails $TimeInfo.WindowsTime -Result ($TimeInfo.SecondsDifference.ToString() + " Seconds Off") -AlertLevel "Critical" -ResultDetails "Local System Time is Off by More Than 5 Minutes" } ELSEIF ($TimeInfo.SecondsDifference -gt 120) { $Results += AddResults -Category "Time & Locale" -Item "System Time" -ItemDetails $TimeInfo.WindowsTime -Result ($TimeInfo.SecondsDifference.ToString() + " Seconds Off") -AlertLevel "Error" -ResultDetails "Local System Time is Off by More Than 2 Minutes" } ELSEIF ($TimeInfo.SecondsDifference -gt 30) { $Results += AddResults -Category "Time & Locale" -Item "System Time" -ItemDetails $TimeInfo.WindowsTime -Result ($TimeInfo.SecondsDifference.ToString() + " Seconds Off") -AlertLevel "Warning" -ResultDetails "Local System Time is Off by More Than 30 Seconds" } ELSE { $Results += AddResults -Category "Time & Locale" -Item "System Time" -ItemDetails $TimeInfo.WindowsTime -Result ($TimeInfo.SecondsDifference.ToString() + " Seconds Off") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### City IF ($True) { $Results += AddResults -Category "Time & Locale" -Item "Location" -ItemDetails "City, State" -Result ($InternetInfo.City + ", " + $InternetInfo.State) -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### Check Country IF ($True) { IF ($InternetInfo.Country -eq "United States") { $Results += AddResults -Category "Time & Locale" -Item "Location" -ItemDetails "Country" -Result $InternetInfo.Country -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "Time & Locale" -Item "Location" -ItemDetails "Country" -Result $InternetInfo.Country -AlertLevel "Warning" -ResultDetails "Computer is Located Outside the US" } } ### ZipCode IF ($True) { $Results += AddResults -Category "Time & Locale" -Item "Location" -ItemDetails "ZipCode" -Result $InternetInfo.ZipCode -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ################################## ####### Internet Category ######## ################################## ### Public IP Address IF ($True) { $Results += AddResults -Category "Internet" -Item "Internet" -ItemDetails "Public IP" -Result $InternetInfo.PublicIP -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### Public IP Address IF ($True) { $Results += AddResults -Category "Internet" -Item "Internet" -ItemDetails "ISP Name" -Result ($InternetInfo.ISP + ", " + $InternetInfo.Org) -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### Internet Speed Test IF ($InternetSpeedTest -eq $True) { ### Download Speed IF ($InternetSpeedTestResults.DownloadSpeed -eq "[Error]") { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Speed" -Result $InternetSpeedTestResults.DownloadSpeed -AlertLevel "Error" -ResultDetails "Test Error Indicates Poor Connectivity" } ELSEIF ([INT]($InternetSpeedTestResults.DownloadSpeed.Replace(" Mbps","")) -gt 40) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Speed" -Result $InternetSpeedTestResults.DownloadSpeed -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ([INT]($InternetSpeedTestResults.DownloadSpeed.Replace(" Mbps","")) -gt 20) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Speed" -Result $InternetSpeedTestResults.DownloadSpeed -AlertLevel "Warning" -ResultDetails "Download Speed is Slightly Low" } ELSEIF ([INT]($InternetSpeedTestResults.DownloadSpeed.Replace(" Mbps","")) -gt 10) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Speed" -Result $InternetSpeedTestResults.DownloadSpeed -AlertLevel "Error" -ResultDetails "Download Speed is Low" } ELSE { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Speed" -Result $InternetSpeedTestResults.DownloadSpeed -AlertLevel "Critical" -ResultDetails "Download Speed is Very Low" } ### Download Latency (Avg) IF ($InternetSpeedTestResults.DownloadLatencyAvg -eq "[Error]") { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Latency (Avg)" -Result $InternetSpeedTestResults.DownloadLatencyAvg -AlertLevel "Error" -ResultDetails "Test Error Indicates Poor Connectivity" } ELSEIF ([INT]($InternetSpeedTestResults.DownloadLatencyAvg.Replace(" ms","")) -lt 200) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Latency (Avg)" -Result $InternetSpeedTestResults.DownloadLatencyAvg -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ([INT]($InternetSpeedTestResults.DownloadLatencyAvg.Replace(" ms","")) -lt 400) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Latency (Avg)" -Result $InternetSpeedTestResults.DownloadLatencyAvg -AlertLevel "Warning" -ResultDetails "Download Latency (Avg) is Slightly High" } ELSEIF ([INT]($InternetSpeedTestResults.DownloadLatencyAvg.Replace(" ms","")) -lt 750) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Latency (Avg)" -Result $InternetSpeedTestResults.DownloadLatencyAvg -AlertLevel "Error" -ResultDetails "Download Latency (Avg) is High" } ELSE { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Latency (Avg)" -Result $InternetSpeedTestResults.DownloadLatencyAvg -AlertLevel "Critical" -ResultDetails "Download Latency (Avg) is Very High" } ### Download Latency (High) IF ($InternetSpeedTestResults.DownloadLatencyHigh -eq "[Error]") { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Latency (High)" -Result $InternetSpeedTestResults.DownloadLatencyHigh -AlertLevel "Error" -ResultDetails "Test Error Indicates Poor Connectivity" } ELSEIF ([INT]($InternetSpeedTestResults.DownloadLatencyHigh.Replace(" ms","")) -lt 400) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Latency (High)" -Result $InternetSpeedTestResults.DownloadLatencyHigh -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ([INT]($InternetSpeedTestResults.DownloadLatencyHigh.Replace(" ms","")) -lt 750) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Latency (High)" -Result $InternetSpeedTestResults.DownloadLatencyHigh -AlertLevel "Warning" -ResultDetails "Download Latency (High) is Slightly High" } ELSEIF ([INT]($InternetSpeedTestResults.DownloadLatencyHigh.Replace(" ms","")) -lt 1500) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Latency (High)" -Result $InternetSpeedTestResults.DownloadLatencyHigh -AlertLevel "Error" -ResultDetails "Download Latency (High) is High" } ELSE { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Download Latency (High)" -Result $InternetSpeedTestResults.DownloadLatencyHigh -AlertLevel "Critical" -ResultDetails "Download Latency (High) is Very High" } ### Upload Speed IF ($InternetSpeedTestResults.UploadSpeed -eq "[Error]") { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Speed" -Result $InternetSpeedTestResults.UploadSpeed -AlertLevel "Error" -ResultDetails "Test Error Indicates Poor Connectivity" } ELSEIF ([INT]($InternetSpeedTestResults.UploadSpeed.Replace(" Mbps","")) -gt 15) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Speed" -Result $InternetSpeedTestResults.UploadSpeed -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ([INT]($InternetSpeedTestResults.UploadSpeed.Replace(" Mbps","")) -gt 10) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Speed" -Result $InternetSpeedTestResults.UploadSpeed -AlertLevel "Warning" -ResultDetails "Upload Speed is Slightly Low" } ELSEIF ([INT]($InternetSpeedTestResults.UploadSpeed.Replace(" Mbps","")) -gt 5) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Speed" -Result $InternetSpeedTestResults.UploadSpeed -AlertLevel "Error" -ResultDetails "Upload Speed is Low" } ELSE { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Speed" -Result $InternetSpeedTestResults.UploadSpeed -AlertLevel "Critical" -ResultDetails "Upload Speed is Very Low" } ### Upload Latency (Avg) IF ($InternetSpeedTestResults.UploadLatencyAvg -eq "[Error]") { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Latency (Avg)" -Result $InternetSpeedTestResults.UploadLatencyAvg -AlertLevel "Error" -ResultDetails "Test Error Indicates Poor Connectivity" } ELSEIF ([INT]($InternetSpeedTestResults.UploadLatencyAvg.Replace(" ms","")) -lt 200) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Latency (Avg)" -Result $InternetSpeedTestResults.UploadLatencyAvg -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ([INT]($InternetSpeedTestResults.UploadLatencyAvg.Replace(" ms","")) -lt 400) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Latency (Avg)" -Result $InternetSpeedTestResults.UploadLatencyAvg -AlertLevel "Warning" -ResultDetails "Upload Latency (Avg) is Slightly High" } ELSEIF ([INT]($InternetSpeedTestResults.UploadLatencyAvg.Replace(" ms","")) -lt 750) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Latency (Avg)" -Result $InternetSpeedTestResults.UploadLatencyAvg -AlertLevel "Error" -ResultDetails "Upload Latency (Avg) is High" } ELSE { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Latency (Avg)" -Result $InternetSpeedTestResults.UploadLatencyAvg -AlertLevel "Critical" -ResultDetails "Upload Latency (Avg) is Very High" } ### Upload Latency (High) IF ($InternetSpeedTestResults.UploadLatencyHigh -eq "[Error]") { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Latency (High)" -Result $InternetSpeedTestResults.UploadLatencyHigh -AlertLevel "Error" -ResultDetails "Test Error Indicates Poor Connectivity" } ELSEIF ([INT]($InternetSpeedTestResults.UploadLatencyHigh.Replace(" ms","")) -lt 400) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Latency (High)" -Result $InternetSpeedTestResults.UploadLatencyHigh -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ([INT]($InternetSpeedTestResults.UploadLatencyHigh.Replace(" ms","")) -lt 750) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Latency (High)" -Result $InternetSpeedTestResults.UploadLatencyHigh -AlertLevel "Warning" -ResultDetails "Upload Latency (High) is Slightly High" } ELSEIF ([INT]($InternetSpeedTestResults.UploadLatencyHigh.Replace(" ms","")) -lt 1500) { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Latency (High)" -Result $InternetSpeedTestResults.UploadLatencyHigh -AlertLevel "Error" -ResultDetails "Upload Latency (High) is High" } ELSE { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Upload Latency (High)" -Result $InternetSpeedTestResults.UploadLatencyHigh -AlertLevel "Critical" -ResultDetails "Upload Latency (High) is Very High" } ### Packet Loss IF ($InternetSpeedTestResults.PacketLoss -eq "[Error]") { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Packet Loss" -Result $InternetSpeedTestResults.PacketLoss -AlertLevel "Error" -ResultDetails "Test Error Indicates Poor Connectivity" } ELSEIF ($InternetSpeedTestResults.PacketLoss -eq "0%" -or $InternetSpeedTestResults.PacketLoss -eq "1%") { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Packet Loss" -Result $InternetSpeedTestResults.PacketLoss -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($InternetSpeedTestResults.PacketLoss -eq "2%" -or $InternetSpeedTestResults.PacketLoss -eq "3%" -or $InternetSpeedTestResults.PacketLoss -eq "4%") { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Packet Loss" -Result $InternetSpeedTestResults.PacketLoss -AlertLevel "Warning" -ResultDetails "Packet Loss is Slightly High" } ELSEIF ($InternetSpeedTestResults.PacketLoss -eq "5%" -or $InternetSpeedTestResults.PacketLoss -eq "6%" -or $InternetSpeedTestResults.PacketLoss -eq "7%") { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Packet Loss" -Result $InternetSpeedTestResults.PacketLoss -AlertLevel "Error" -ResultDetails "Packet Loss is High" } ELSE { $Results += AddResults -Category "Internet" -Item "Connection" -ItemDetails "Packet Loss" -Result $InternetSpeedTestResults.PacketLoss -AlertLevel "Critical" -ResultDetails "Packet Loss is Very High" } } #################################### ####### Application Category ####### #################################### ### Notable Apps IF ($True) { IF ($ApplicationNotable) { FOREACH ($App in $ApplicationNotable) { $Results += AddResults -Category "Applications" -Item "Notable Application" -ItemDetails $App.Name -Result "Installed" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ELSE { $Results += AddResults -Category "Applications" -Item "Notable Application" -ItemDetails "None" -Result "N/A" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ################################# ####### Hardware Category ####### ################################# ### CPU Score IF ($True) { $ItemDetails = "CPUBenchmark.net Score" FOREACH ($CPU in $CPUs) { IF ($CPU.CPUScore -lt 3500) { $Results += AddResults -Category "Hardware" -Item "CPU" -ItemDetails $ItemDetails -Result $CPU.CPUScore -AlertLevel "Critical" -ResultDetails "Extremely Slow CPU" } ELSEIF ($CPU.CPUScore -lt 5000) { $Results += AddResults -Category "Hardware" -Item "CPU" -ItemDetails $ItemDetails -Result $CPU.CPUScore -AlertLevel "Error" -ResultDetails "Very Slow CPU" } ELSEIF ($CPU.CPUScore -lt 7500) { $Results += AddResults -Category "Hardware" -Item "CPU" -ItemDetails $ItemDetails -Result $CPU.CPUScore -AlertLevel "Warning" -ResultDetails "Slow CPU" } ELSE { $Results += AddResults -Category "Hardware" -Item "CPU" -ItemDetails $ItemDetails -Result $CPU.CPUScore -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } } ### CPU Age IF ($True) { $ItemDetails = "Approximate Age" FOREACH ($CPU in $CPUs) { IF ($CPU.YearsOld -eq "Unknown") { $Results += AddResults -Category "Hardware" -Item "CPU" -ItemDetails $ItemDetails -Result "Unknown" -AlertLevel "Normal" -ResultDetails "Unknown Computer Age" } ELSEIF ($CPU.YearsOld -lt 6) { $Results += AddResults -Category "Hardware" -Item "CPU" -ItemDetails $ItemDetails -Result $CPU.YearsOld.ToString() + " Years" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($CPU.YearsOld -lt 8) { $Results += AddResults -Category "Hardware" -Item "CPU" -ItemDetails $ItemDetails -Result $CPU.YearsOld.ToString() + " Years" -AlertLevel "Warning" -ResultDetails "Old Computer" } ELSEIF ($CPU.YearsOld -lt 10) { $Results += AddResults -Category "Hardware" -Item "CPU" -ItemDetails $ItemDetails -Result $CPU.YearsOld.ToString() + " Years" -AlertLevel "Error" -ResultDetails "Very Old Computer" } ELSE { $Results += AddResults -Category "Hardware" -Item "CPU" -ItemDetails $ItemDetails -Result $CPU.YearsOld.ToString() + " Years" -AlertLevel "Critical" -ResultDetails "Extremely Old Computer" } } } ### Available RAM IF ($True) { IF ($AvailableMemoryGBs -gt 1) { $Results += AddResults -Category "Hardware" -Item "RAM" -ItemDetails "Available RAM" -Result ($AvailableMemoryGBs.ToString() + " GBs") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($AvailableMemoryGBs -gt .5) { $Results += AddResults -Category "Hardware" -Item "RAM" -ItemDetails "Available RAM" -Result ($AvailableMemoryGBs.ToString() + " GBs") -AlertLevel "Warning" -ResultDetails "Low Available RAM" } ELSEIF ($AvailableMemoryGBs -gt .25) { $Results += AddResults -Category "Hardware" -Item "RAM" -ItemDetails "Available RAM" -Result ($AvailableMemoryGBs.ToString() + " GBs") -AlertLevel "Error" -ResultDetails "Very Low Available RAM" } ELSE { $Results += AddResults -Category "Hardware" -Item "RAM" -ItemDetails "Available RAM" -Result ($AvailableMemoryGBs.ToString() + " GBs") -AlertLevel "Critical" -ResultDetails "Extremely Low Available RAM" } } ### Disk Type IF ($True) { IF ($OSDriveType -eq "HDD") { $Results += AddResults -Category "Hardware" -Item "Storage" -ItemDetails "Disk Type (OS Vol)" -Result $OSDriveType -AlertLevel "Warning" -ResultDetails "OS Drive is HDD" } ELSE { $Results += AddResults -Category "Hardware" -Item "Storage" -ItemDetails "Disk Type (OS Vol)" -Result $OSDriveType -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### Disk Free Space IF ($True) { IF ($SystemVolume.VolumeFreeSizeInGBs -lt 2) { $Results += AddResults -Category "Hardware" -Item "Storage" -ItemDetails "Free Space (OS Vol)" -Result ($SystemVolume.VolumeFreeSizeInGBs.ToString() + " GBs") -AlertLevel "Critical" -ResultDetails "Extremely Low Disk Space" } ELSEIF ($SystemVolume.VolumeFreeSizeInGBs -lt 5) { $Results += AddResults -Category "Hardware" -Item "Storage" -ItemDetails "Free Space (OS Vol)" -Result ($SystemVolume.VolumeFreeSizeInGBs.ToString() + " GBs") -AlertLevel "Error" -ResultDetails "Very Low Disk Space" } ELSEIF ($SystemVolume.VolumeFreeSizeInGBs -lt 25) { $Results += AddResults -Category "Hardware" -Item "Storage" -ItemDetails "Free Space (OS Vol)" -Result ($SystemVolume.VolumeFreeSizeInGBs.ToString() + " GBs") -AlertLevel "Warning" -ResultDetails "Low Disk Space" } ELSE { $Results += AddResults -Category "Hardware" -Item "Storage" -ItemDetails "Free Space (OS Vol)" -Result ($SystemVolume.VolumeFreeSizeInGBs.ToString() + " GBs") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### Disk Performance Test IF ($True) { FOREACH ($DiskSpeedTestResult in $DiskSpeedTestResults) { $TestName = $DiskSpeedTestResult.IOType + " " + $DiskSpeedTestResult.AccessType IF ($DiskSpeedTestResult.IOType -eq "Random" -and $DiskSpeedTestResult.AccessType -eq "Read") { IF ($DiskSpeedTestResult.ResultMBs -gt 35) { $AlertLevel = "Normal"; $ResultDetails = $NoIssuesFound } ELSEIF ($DiskSpeedTestResult.ResultMBs -gt 20) { $AlertLevel = "Warning"; $ResultDetails = "$TestName Speed is Slightly Slow" } ELSEIF ($DiskSpeedTestResult.ResultMBs -gt 10) { $AlertLevel = "Error"; $ResultDetails = "$TestName Speed is Slow" } ELSE { $AlertLevel = "Critical"; $ResultDetails = "$TestName Speed is Very Slow" } $Results += AddResults -Category "Hardware" -Item "Storage" -ItemDetails $TestName -Result "$($DiskSpeedTestResult.ResultMBs) MB/s" -AlertLevel $AlertLevel -ResultDetails $ResultDetails } IF ($DiskSpeedTestResult.IOType -eq "Random" -and $DiskSpeedTestResult.AccessType -eq "Write") { IF ($DiskSpeedTestResult.ResultMBs -gt 25) { $AlertLevel = "Normal"; $ResultDetails = $NoIssuesFound } ELSEIF ($DiskSpeedTestResult.ResultMBs -gt 10) { $AlertLevel = "Warning"; $ResultDetails = "$TestName Speed is Slightly Slow" } ELSEIF ($DiskSpeedTestResult.ResultMBs -gt 5) { $AlertLevel = "Error"; $ResultDetails = "$TestName Speed is Slow" } ELSE { $AlertLevel = "Critical"; $ResultDetails = "$TestName Speed is Very Slow" } $Results += AddResults -Category "Hardware" -Item "Storage" -ItemDetails $TestName -Result "$($DiskSpeedTestResult.ResultMBs) MB/s" -AlertLevel $AlertLevel -ResultDetails $ResultDetails } IF ($DiskSpeedTestResult.IOType -eq "Sequential" -and $DiskSpeedTestResult.AccessType -eq "Read") { IF ($DiskSpeedTestResult.ResultMBs -gt 100) { $AlertLevel = "Normal"; $ResultDetails = $NoIssuesFound } ELSEIF ($DiskSpeedTestResult.ResultMBs -gt 50) { $AlertLevel = "Warning"; $ResultDetails = "$TestName Speed is Slightly Slow" } ELSEIF ($DiskSpeedTestResult.ResultMBs -gt 25) { $AlertLevel = "Error"; $ResultDetails = "$TestName Speed is Slow" } ELSE { $AlertLevel = "Critical"; $ResultDetails = "$TestName Speed is Very Slow" } $Results += AddResults -Category "Hardware" -Item "Storage" -ItemDetails $TestName -Result "$($DiskSpeedTestResult.ResultMBs) MB/s" -AlertLevel $AlertLevel -ResultDetails $ResultDetails } IF ($DiskSpeedTestResult.IOType -eq "Sequential" -and $DiskSpeedTestResult.AccessType -eq "Write") { IF ($DiskSpeedTestResult.ResultMBs -gt 70) { $AlertLevel = "Normal"; $ResultDetails = $NoIssuesFound } ELSEIF ($DiskSpeedTestResult.ResultMBs -gt 35) { $AlertLevel = "Warning"; $ResultDetails = "$TestName Speed is Slightly Slow" } ELSEIF ($DiskSpeedTestResult.ResultMBs -gt 15) { $AlertLevel = "Error"; $ResultDetails = "$TestName Speed is Slow" } ELSE { $AlertLevel = "Critical"; $ResultDetails = "$TestName Speed is Very Slow" } $Results += AddResults -Category "Hardware" -Item "Storage" -ItemDetails $TestName -Result "$($DiskSpeedTestResult.ResultMBs) MB/s" -AlertLevel $AlertLevel -ResultDetails $ResultDetails } } } ################################# ####### Security Category ####### ################################# ### Last Security Update IF ($True) { $SecurityTimespan = $Now - $OSInfo.LastWindowsUpdate IF ($SecurityTimespan.TotalDays -le 45) { $AlertLevel = "Normal"; $Details = $NoIssuesFound } ELSEIF ($SecurityTimespan.TotalDays -le 90) { $AlertLevel = "Warning"; $Details = "Windows Security Last Applied $([int]$($SecurityTimeSpan.TotalDays)) Days Ago" } ELSEIF ($SecurityTimespan.TotalDays -le 135) { $AlertLevel = "Error"; $Details = "Windows Security Last Applied $([int]$($SecurityTimeSpan.TotalDays)) Days Ago" } ELSE { $AlertLevel = "Critical"; $Details = "Windows Security Last Applied $([int]$($SecurityTimeSpan.TotalDays)) Days Ago" } $Results += AddResults -Category "Security" -Item "Windows Update" -ItemDetails "Most Recent Update" -Result $OSInfo.LastWindowsUpdate -AlertLevel $AlertLevel -ResultDetails $Details } ### TPM Status IF ($True) { IF ($TPM.TPMPresent -eq "True") { $Results += AddResults -Category "Security" -Item "TPM Chip" -ItemDetails "Is Present" -Result $TPM.TPMPresent -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "Security" -Item "TPM Chip" -ItemDetails "Is Present" -Result $TPM.TPMPresent -AlertLevel "Warning" -ResultDetails "No TPM Chip is Present" } } ### BitLocker Status IF ($True) { IF ($OSInfo.UnencryptedDrives.Count -eq 0) { $Results += AddResults -Category "Security" -Item "BitLocker" -ItemDetails "Encrypted Drives" -Result $OSInfo.BitLockerEncryptedDrives -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { IF ($OSInfo.BitLockerEncryptedDrives.Count -eq 0) { $EncryptDrives = "None" } ELSE { $EncryptDrives -eq $OSInfo.BitLockerEncryptedDrives } IF ($ChassisInfo.ChassisType -eq "Laptop") { $Results += AddResults -Category "Security" -Item "BitLocker" -ItemDetails "Encrypted Drives" -Result $EncryptDrives -AlertLevel "Warning" -ResultDetails ("Laptop Drives Not Encrypted: $($OSInfo.UnencryptedDrives)") } ELSE { $Results += AddResults -Category "Security" -Item "BitLocker" -ItemDetails "Encrypted Drives" -Result $EncryptDrives -AlertLevel "Normal" -ResultDetails ("Drives Not Encrypted: $($OSInfo.UnencryptedDrives)") } } } ### Hosts File IF ($True) { IF (Test-IsHostsFileModified) { $Results += AddResults -Category "Security" -Item "Hosts File" -ItemDetails "Modified Status" -Result "Modified" -AlertLevel "Warning" -ResultDetails "Hosts File Has Been Modified" } ELSE { $Results += AddResults -Category "Security" -Item "Hosts File" -ItemDetails "Modified Status" -Result "Unmodified" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### Crypto Protocls IF ($True) { $EnabledProtocols = @() FOREACH ($Protocol in ($CryptoProtocols | Where-Object { $_.Status -eq "Enabled" })) { $EnabledProtocols += $Protocol.Protocol } IF ($EnabledProtocols -contains "TLS 1.0" -or $EnabledProtocols -contains "TLS 1.1") { $Results += AddResults -Category "Security" -Item "TLS" -ItemDetails "Enabled Protocols" -Result $EnabledProtocols -AlertLevel "Warning" -ResultDetails "Deprecated Protocols are Enabled" } ELSE { $Results += AddResults -Category "Security" -Item "TLS" -ItemDetails "Enabled Protocols" -Result $EnabledProtocols -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ############################ ####### DNS Category ####### ############################ ### DNS IF ($True) { FOREACH ($Item in $InternalDNS) { IF ($Item.FailCount -gt 0) { $Results += AddResults -Category "DNS" -Item "Internal" -ItemDetails $Item.Name -Result "$($Item.FailCount.ToString()) of $($Item.TestCount.ToString()) DNS Queries Failed" -AlertLevel $Item.Verdict -ResultDetails "DNS is Not Properly Resolving $($Item.Name)" } ELSE { $Results += AddResults -Category "DNS" -Item "Internal" -ItemDetails $Item.Name -Result "DNS Resolving Successfully" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } FOREACH ($Item in $ExternalDNS) { IF ($Item.FailCount -gt 0) { $Results += AddResults -Category "DNS" -Item "External" -ItemDetails $Item.Name -Result "$($Item.FailCount.ToString()) of $($Item.TestCount.ToString()) DNS Queries Failed" -AlertLevel $Item.Verdict -ResultDetails "DNS is Not Properly Resolving $($Item.Name)" } ELSE { $Results += AddResults -Category "DNS" -Item "External" -ItemDetails $Item.Name -Result "DNS Resolving Successfully" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } } ################################ ####### Network Category ####### ################################ ### Network Connections IF ($True) { FOREACH ($NetworkConnection in $NetworkConnections) { $AdapterType = $NetworkConnection.Type IF ($NetworkConnection.IPAssignment -eq "DHCP") { $IsDHCP = $True; $IsStatic = $False } ELSE { $IsDHCP = $False; $IsStatic = $True } ### Connections IF ($NetworkConnection.Type -like "*WiFi*" -and $NetworkConnection.Status -eq "Connected") { ### Connection Status IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Status" -Result $NetworkConnection.Status -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Address IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Address" -Result $NetworkConnection.IPAddress -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Assignment Type IF ($True) { IF ($IsWorkstation -and $IsDHCP) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($IsServer -and $IsStatic) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($IsWorkstation -and $IsStatic) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Warning" -ResultDetails "Workstation Has Static IP Assignment" } ELSEIF ($IsServer -and $IsDHCP) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Warning" -ResultDetails "Server Has DHCP IP Assignment" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### IPv4 DNS IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Server" -Result $NetworkConnection.DNSServer -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 DNS Assignment Type IF ($True) { IF (($IsWorkstation) -and $NetworkConnection.DNSAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Critical" -ResultDetails "Workstation Has Static DNS Assignment" } ELSEIF (($IsServer) -and $NetworkConnection.DNSAssignment -eq "DHCP") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Warning" -ResultDetails "Server Has DHCP DNS Assignment" } ELSEIF ($NetworkConnection.DNSAssignment -eq "DHCP" -or $NetworkConnection.DNSAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE {} } ### SSID IF ($True) { IF ($NetworkConnection.SSID -like "*guest*") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "SSID" -Result $NetworkConnection.SSID -AlertLevel "Warning" -ResultDetails "Connected to Guest Network" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "SSID" -Result $NetworkConnection.SSID -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### Protocol IF ($True) { IF ($NetworkConnection.Protocol -like "*ac*" -or $NetworkConnection.Protocol -like "*ax*") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Protocol" -Result $NetworkConnection.Protocol -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Protocol" -Result $NetworkConnection.Protocol -AlertLevel "Warning" -ResultDetails "Connected with WiFi 4 or Below" } } ### Signal Strength IF ($True) { $SignalStrength = $NetworkConnection.SignalStrength.Replace("%","") [int]$SignalStrength = [int]$SignalStrength.Replace(" ","") IF ($SignalStrength -ge 70) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails $NetworkConnection.Name -Result $NetworkConnection.SignalStrength -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($SignalStrength -ge 60) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails $NetworkConnection.Name -Result $NetworkConnection.SignalStrength -AlertLevel "Warning" -ResultDetails "Low Signal Strength" } ELSEIF ($SignalStrength -ge 50) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails $NetworkConnection.Name -Result $NetworkConnection.SignalStrength -AlertLevel "Error" -ResultDetails "Very Low Signal Strength" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails $NetworkConnection.Name -Result $NetworkConnection.SignalStrength -AlertLevel "Critical" -ResultDetails "Extremely Low Signal Strength" } } ### Link Speed IF ($True) { IF ($NetworkConnection.LinkSpeed -eq "" -or $null -eq $NetworkConnection.LinkSpeed) {} ELSEIF ($NetworkConnection.LinkSpeed -eq "Disconnected") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result $NetworkConnection.LinkSpeed -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $LinkSpeedCalc = 0 $LinkSpeed = $NetworkConnection.LinkSpeed.Split("\") IF (($LinkSpeed[0]/4) -lt $LinkSpeed[1]) { [int]$LinkSpeedCalc = $LinkSpeed[0] / 4 } ELSE { [int]$LinkSpeedCalc = $LinkSpeed[1] } IF ($LinkSpeedCalc -gt 75) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($LinkSpeedCalc -gt 50) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Warning" -ResultDetails "Slow Link Speed" } ELSEIF ($LinkSpeedCalc -gt 25) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Error" -ResultDetails "Very Slow Link Speed" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Critical" -ResultDetails "Extremely Slow Link Speed" } } } ### Connection Profile IF ($True) { IF ($IsServer -and $IsADJoined -and ($NetworkConnection.ConnectionProfile -ne "DomainAuthenticated")) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Connection Profile" -Result $NetworkConnection.ConnectionProfile -AlertLevel "Critical" -ResultDetails "Domain Server Profile Not Domain Authenticated" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Connection Profile" -Result $NetworkConnection.ConnectionProfile -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### DNS Suffix IF ($True) { ### Get Suffixes $SuffixResult = @() IF ($NetworkConnection.DNSSuffix -is [array]) { $SuffixResult += $NetworkConnection.DNSSuffix } ELSEIF ($NetworkConnection.DNSSuffix -isnot [array] -and $NetworkConnection.DNSSuffix -ne "" -and $Null -ne $NetworkConnection.DNSSuffix) { $SuffixResult += $NetworkConnection.DNSSuffix } IF ($GlobalDNSSuffixes.Count -ne 0) { $SuffixResult += $GlobalDNSSuffixes } ### Results IF (($SuffixResult -is [array] -and $SuffixResult.Count -gt 0) -or ($SuffixResult -isnot [array] -and $SuffixResult.Length -gt 2)) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Suffix" -Result ($SuffixResult -join ", ") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { FOREACH ($Suffix in $NetworkConnection.DNSSuffix) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Suffix" -Result "[None]" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } } } IF ($NetworkConnection.Type -like "*WiFi*" -and $NetworkConnection.Status -ne "Connected") { ### Connection Status IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Status" -Result $NetworkConnection.Status -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Address IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Address" -Result $NetworkConnection.IPAddress -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Assignment Type IF ($True) { IF ($IsWorkstation -and $IsDHCP) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($IsServer -and $IsStatic) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($IsWorkstation -and $IsStatic) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Warning" -ResultDetails "Workstation Has Static IP Assignment" } ELSEIF ($IsServer -and $IsDHCP) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Warning" -ResultDetails "Server Has DHCP IP Assignment" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### IPv4 DNS IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Server" -Result $NetworkConnection.DNSServer -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 DNS Assignment Type IF ($True) { IF (($IsWorkstation) -and $NetworkConnection.DNSAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Critical" -ResultDetails "Workstation Has Static DNS Assignment" } ELSEIF (($IsServer) -and $NetworkConnection.DNSAssignment -eq "DHCP") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Warning" -ResultDetails "Server Has DHCP DNS Assignment" } ELSEIF ($NetworkConnection.DNSAssignment -eq "DHCP" -or $NetworkConnection.DNSAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE {} } ### Link Speed IF ($True) { IF ($NetworkConnection.LinkSpeed -eq "" -or $null -eq $NetworkConnection.LinkSpeed) {} ELSEIF ($NetworkConnection.LinkSpeed -eq "Disconnected") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result $NetworkConnection.LinkSpeed -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $LinkSpeedCalc = 0 $LinkSpeed = $NetworkConnection.LinkSpeed.Split("\") IF (($LinkSpeed[0]/4) -lt $LinkSpeed[1]) { [int]$LinkSpeedCalc = $LinkSpeed[0] / 4 } ELSE { [int]$LinkSpeedCalc = $LinkSpeed[1] } IF ($LinkSpeedCalc -gt 75) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($LinkSpeedCalc -gt 50) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Warning" -ResultDetails "Slow Link Speed" } ELSEIF ($LinkSpeedCalc -gt 25) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Error" -ResultDetails "Very Slow Link Speed" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Critical" -ResultDetails "Extremely Slow Link Speed" } } } ### DNS Suffix IF ($True) { ### Get Suffixes $SuffixResult = @() IF ($NetworkConnection.DNSSuffix -is [array]) { $SuffixResult += $NetworkConnection.DNSSuffix } ELSEIF ($NetworkConnection.DNSSuffix -isnot [array] -and $NetworkConnection.DNSSuffix -ne "" -and $Null -ne $NetworkConnection.DNSSuffix) { $SuffixResult += $NetworkConnection.DNSSuffix } IF ($GlobalDNSSuffixes.Count -ne 0) { $SuffixResult += $GlobalDNSSuffixes } ### Results IF (($SuffixResult -is [array] -and $SuffixResult.Count -gt 0) -or ($SuffixResult -isnot [array] -and $SuffixResult.Length -gt 2)) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Suffix" -Result ($SuffixResult -join ", ") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { FOREACH ($Suffix in $NetworkConnection.DNSSuffix) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Suffix" -Result "[None]" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } } } IF ($NetworkConnection.Type -like "*Wired*" -and $NetworkConnection.Status -eq "Connected") { ### Connection Status IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Status" -Result $NetworkConnection.Status -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Address IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Address" -Result $NetworkConnection.IPAddress -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Assignment Type IF ($True) { IF ($OSInfo.Type -eq "Workstation" -and $NetworkConnection.IPAssignment -eq "DHCP") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($OSInfo.Type -ne "Server" -and $NetworkConnection.IPAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($OSInfo.Type -eq "Workstation" -and $NetworkConnection.IPAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Warning" -ResultDetails "Workstation Has Static IP Assignment" } ELSEIF ($OSInfo.Type -ne "Server" -and $NetworkConnection.IPAssignment -eq "DHCP") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Warning" -ResultDetails "Server Has DHCP IP Assignment" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### IPv4 DNS IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Server" -Result $NetworkConnection.DNSServer -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 DNS Assignment Type IF ($True) { IF (($IsWorkstation) -and $NetworkConnection.DNSAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Critical" -ResultDetails "Workstation Has Static DNS Assignment" } ELSEIF (($IsServer) -and $NetworkConnection.DNSAssignment -eq "DHCP") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Warning" -ResultDetails "Server Has DHCP DNS Assignment" } ELSEIF ($NetworkConnection.DNSAssignment -eq "DHCP" -or $NetworkConnection.DNSAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE {} } ### Link Speed IF ($True) { IF ($NetworkConnection.LinkSpeed -eq "" -or $null -eq $NetworkConnection.LinkSpeed) {} ELSEIF ($NetworkConnection.LinkSpeed -eq "Disconnected") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result $NetworkConnection.LinkSpeed -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $LinkSpeedCalc = 0 $LinkSpeed = $NetworkConnection.LinkSpeed.Split("\") IF (($LinkSpeed[0]/4) -lt $LinkSpeed[1]) { [int]$LinkSpeedCalc = $LinkSpeed[0] / 4 } ELSE { [int]$LinkSpeedCalc = $LinkSpeed[1] } IF ($LinkSpeedCalc -gt 75) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($LinkSpeedCalc -gt 50) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Warning" -ResultDetails "Slow Link Speed" } ELSEIF ($LinkSpeedCalc -gt 25) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Error" -ResultDetails "Very Slow Link Speed" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Critical" -ResultDetails "Extremely Slow Link Speed" } } } ### Connection Profile IF ($True) { IF ($IsServer -and $IsADJoined -and ($NetworkConnection.ConnectionProfile -ne "DomainAuthenticated")) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Connection Profile" -Result $NetworkConnection.ConnectionProfile -AlertLevel "Critical" -ResultDetails "Domain Server Profile Not Domain Authenticated" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Connection Profile" -Result $NetworkConnection.ConnectionProfile -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### DNS Suffix IF ($True) { ### Get Suffixes $SuffixResult = @() IF ($NetworkConnection.DNSSuffix -is [array]) { $SuffixResult += $NetworkConnection.DNSSuffix } ELSEIF ($NetworkConnection.DNSSuffix -isnot [array] -and $NetworkConnection.DNSSuffix -ne "" -and $Null -ne $NetworkConnection.DNSSuffix) { $SuffixResult += $NetworkConnection.DNSSuffix } IF ($GlobalDNSSuffixes.Count -ne 0) { $SuffixResult += $GlobalDNSSuffixes } ### Results IF (($SuffixResult -is [array] -and $SuffixResult.Count -gt 0) -or ($SuffixResult -isnot [array] -and $SuffixResult.Length -gt 2)) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Suffix" -Result ($SuffixResult -join ", ") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { FOREACH ($Suffix in $NetworkConnection.DNSSuffix) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Suffix" -Result "[None]" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } } } IF ($NetworkConnection.Type -like "*Wired*" -and $NetworkConnection.Status -ne "Connected") { ### Connection Status IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Status" -Result $NetworkConnection.Status -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Address IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Address" -Result $NetworkConnection.IPAddress -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Assignment Type IF ($True) { IF ($IsWorkstation -and $IsDHCP) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($IsServer -and $IsStatic) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($IsWorkstation -and $IsStatic) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Warning" -ResultDetails "Workstation Has Static IP Assignment" } ELSEIF ($IsServer -and $IsDHCP) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Warning" -ResultDetails "Server Has DHCP IP Assignment" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### IPv4 DNS IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Server" -Result $NetworkConnection.DNSServer -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 DNS Assignment Type IF ($True) { IF (($IsWorkstation) -and $NetworkConnection.DNSAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Critical" -ResultDetails "Workstation Has Static DNS Assignment" } ELSEIF (($IsServer) -and $NetworkConnection.DNSAssignment -eq "DHCP") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Warning" -ResultDetails "Server Has DHCP DNS Assignment" } ELSEIF ($NetworkConnection.DNSAssignment -eq "DHCP" -or $NetworkConnection.DNSAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE {} } ### Link Speed IF ($True) { IF ($NetworkConnection.LinkSpeed -eq "" -or $null -eq $NetworkConnection.LinkSpeed) {} ELSEIF ($NetworkConnection.Status -eq "Disconnected") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result $NetworkConnection.LinkSpeed -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $LinkSpeedCalc = 0 $LinkSpeed = $NetworkConnection.LinkSpeed.Split("\") IF (($LinkSpeed[0]/4) -lt $LinkSpeed[1]) { [int]$LinkSpeedCalc = $LinkSpeed[0] / 4 } ELSE { [int]$LinkSpeedCalc = $LinkSpeed[1] } IF ($LinkSpeedCalc -gt 75) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($LinkSpeedCalc -gt 50) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Warning" -ResultDetails "Slow Link Speed" } ELSEIF ($LinkSpeedCalc -gt 25) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Error" -ResultDetails "Very Slow Link Speed" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Critical" -ResultDetails "Extremely Slow Link Speed" } } } ### DNS Suffix IF ($True) { ### Get Suffixes $SuffixResult = @() IF ($NetworkConnection.DNSSuffix -is [array]) { $SuffixResult += $NetworkConnection.DNSSuffix } ELSEIF ($NetworkConnection.DNSSuffix -isnot [array] -and $NetworkConnection.DNSSuffix -ne "" -and $Null -ne $NetworkConnection.DNSSuffix) { $SuffixResult += $NetworkConnection.DNSSuffix } IF ($GlobalDNSSuffixes.Count -ne 0) { $SuffixResult += $GlobalDNSSuffixes } ### Results IF (($SuffixResult -is [array] -and $SuffixResult.Count -gt 0) -or ($SuffixResult -isnot [array] -and $SuffixResult.Length -gt 2)) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Suffix" -Result ($SuffixResult -join ", ") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { FOREACH ($Suffix in $NetworkConnection.DNSSuffix) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Suffix" -Result "[None]" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } } } IF ($NetworkConnection.Type -like "*Hyper*" -and $NetworkConnection.Status -eq "Connected") { ### Connection Status IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Status" -Result $NetworkConnection.Status -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Address IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Address" -Result $NetworkConnection.IPAddress -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Assignment Type IF ($True) { IF ($IsWorkstation -and $IsDHCP) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($IsServer -and $IsStatic) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($IsWorkstation -and $IsStatic) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Warning" -ResultDetails "Workstation Has Static IP Assignment" } ELSEIF ($IsServer -and $IsDHCP) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Warning" -ResultDetails "Server Has DHCP IP Assignment" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### IPv4 DNS IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Server" -Result $NetworkConnection.DNSServer -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 DNS Assignment Type IF ($True) { IF (($IsWorkstation) -and $NetworkConnection.DNSAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Critical" -ResultDetails "Workstation Has Static DNS Assignment" } ELSEIF (($IsServer) -and $NetworkConnection.DNSAssignment -eq "DHCP") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Warning" -ResultDetails "Server Has DHCP DNS Assignment" } ELSEIF ($NetworkConnection.DNSAssignment -eq "DHCP" -or $NetworkConnection.DNSAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE {} } ### Link Speed IF ($True) { IF ($NetworkConnection.LinkSpeed -eq "" -or $null -eq $NetworkConnection.LinkSpeed) {} ELSEIF ($NetworkConnection.LinkSpeed -eq "Disconnected") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result $NetworkConnection.LinkSpeed -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $LinkSpeedCalc = 0 $LinkSpeed = $NetworkConnection.LinkSpeed.Split("\") IF (($LinkSpeed[0]/4) -lt $LinkSpeed[1]) { [int]$LinkSpeedCalc = $LinkSpeed[0] / 4 } ELSE { [int]$LinkSpeedCalc = $LinkSpeed[1] } IF ($LinkSpeedCalc -gt 75) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($LinkSpeedCalc -gt 50) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Warning" -ResultDetails "Slow Link Speed" } ELSEIF ($LinkSpeedCalc -gt 25) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Error" -ResultDetails "Very Slow Link Speed" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Critical" -ResultDetails "Extremely Slow Link Speed" } } } ### Parent Adapters IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Parent Adapter" -Result $NetworkConnection.ParentAdapter -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### Connection Profile IF ($True) { IF ($IsServer -and $IsADJoined -and ($NetworkConnection.ConnectionProfile -ne "DomainAuthenticated")) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Connection Profile" -Result $NetworkConnection.ConnectionProfile -AlertLevel "Critical" -ResultDetails "Domain Server Profile Not Domain Authenticated" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Connection Profile" -Result $NetworkConnection.ConnectionProfile -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### DNS Suffix IF ($True) { ### Get Suffixes $SuffixResult = @() IF ($NetworkConnection.DNSSuffix -is [array]) { $SuffixResult += $NetworkConnection.DNSSuffix } ELSEIF ($NetworkConnection.DNSSuffix -isnot [array] -and $NetworkConnection.DNSSuffix -ne "" -and $Null -ne $NetworkConnection.DNSSuffix) { $SuffixResult += $NetworkConnection.DNSSuffix } IF ($GlobalDNSSuffixes.Count -ne 0) { $SuffixResult += $GlobalDNSSuffixes } ### Results IF (($SuffixResult -is [array] -and $SuffixResult.Count -gt 0) -or ($SuffixResult -isnot [array] -and $SuffixResult.Length -gt 2)) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Suffix" -Result ($SuffixResult -join ", ") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { FOREACH ($Suffix in $NetworkConnection.DNSSuffix) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Suffix" -Result "[None]" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } } } IF ($NetworkConnection.Type -like "*Hyper*" -and $NetworkConnection.Status -ne "Connected") { ### Connection Status IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Status" -Result $NetworkConnection.Status -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Address IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Address" -Result $NetworkConnection.IPAddress -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Assignment Type IF ($True) { IF ($IsWorkstation -and $IsDHCP) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($IsServer -and $IsStatic) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($IsWorkstation -and $IsStatic) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Warning" -ResultDetails "Workstation Has Static IP Assignment" } ELSEIF ($IsServer -and $IsDHCP) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Warning" -ResultDetails "Server Has DHCP IP Assignment" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "IP Assignment" -Result $NetworkConnection.IPAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } ### IPv4 DNS IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Server" -Result $NetworkConnection.DNSServer -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 DNS Assignment Type IF ($True) { IF (($IsWorkstation) -and $NetworkConnection.DNSAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Critical" -ResultDetails "Workstation Has Static DNS Assignment" } ELSEIF (($IsServer) -and $NetworkConnection.DNSAssignment -eq "DHCP") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Warning" -ResultDetails "Server Has DHCP DNS Assignment" } ELSEIF ($NetworkConnection.DNSAssignment -eq "DHCP" -or $NetworkConnection.DNSAssignment -eq "Static") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Assignment" -Result $NetworkConnection.DNSAssignment -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE {} } ### Link Speed IF ($True) { IF ($NetworkConnection.LinkSpeed -eq "" -or $null -eq $NetworkConnection.LinkSpeed) {} ELSEIF ($NetworkConnection.LinkSpeed -eq "Disconnected") { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result $NetworkConnection.LinkSpeed -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { $LinkSpeedCalc = 0 $LinkSpeed = $NetworkConnection.LinkSpeed.Split("\") IF (($LinkSpeed[0]/4) -lt $LinkSpeed[1]) { [int]$LinkSpeedCalc = $LinkSpeed[0] / 4 } ELSE { [int]$LinkSpeedCalc = $LinkSpeed[1] } IF ($LinkSpeedCalc -gt 75) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSEIF ($LinkSpeedCalc -gt 50) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Warning" -ResultDetails "Slow Link Speed" } ELSEIF ($LinkSpeedCalc -gt 25) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Error" -ResultDetails "Very Slow Link Speed" } ELSE { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Link Speed" -Result ($NetworkConnection.LinkSpeed + " Mbps") -AlertLevel "Critical" -ResultDetails "Extremely Slow Link Speed" } } } ### Parent Adapters IF ($True) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "Parent Adapter" -Result $NetworkConnection.ParentAdapter -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### DNS Suffix IF ($True) { ### Get Suffixes $SuffixResult = @() IF ($NetworkConnection.DNSSuffix -is [array]) { $SuffixResult += $NetworkConnection.DNSSuffix } ELSEIF ($NetworkConnection.DNSSuffix -isnot [array] -and $NetworkConnection.DNSSuffix -ne "" -and $Null -ne $NetworkConnection.DNSSuffix) { $SuffixResult += $NetworkConnection.DNSSuffix } IF ($GlobalDNSSuffixes.Count -ne 0) { $SuffixResult += $GlobalDNSSuffixes } ### Results IF (($SuffixResult -is [array] -and $SuffixResult.Count -gt 0) -or ($SuffixResult -isnot [array] -and $SuffixResult.Length -gt 2)) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Suffix" -Result ($SuffixResult -join ", ") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { FOREACH ($Suffix in $NetworkConnection.DNSSuffix) { $Results += AddResults -Category "$($NetworkConnection.Name)" -Item $AdapterType -ItemDetails "DNS Suffix" -Result "[None]" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } } } IF ($NetworkConnection.Type -like "*VPN*") { ### Connection Status IF ($True) { $Results += AddResults -Category "$($VPNConnection.Name)" -Item $VPNConnection.Type -ItemDetails "Status" -Result $VPNConnection.ConnectionState -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### IPv4 Address IF ($True) { $Results += AddResults -Category "$($VPNConnection.Name)" -Item $VPNConnection.Type -ItemDetails "IP Address" -Result $VPNConnection.IPAddress -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### DNS Servers IF ($True) { $Results += AddResults -Category "$($VPNConnection.Name)" -Item $VPNConnection.Type -ItemDetails "DNS Servers" -Result $VPNConnection.DNSServers -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ### DNS Suffix IF ($True) { ### Get Suffixes $SuffixResult = @() IF ($VPNConnection.DNSSuffix -is [array]) { $SuffixResult += $NetworkConnection.DNSSuffix } ELSEIF ($VPNConnection.DNSSuffix -isnot [array] -and $VPNConnection.DNSSuffix -ne "" -and $Null -ne $VPNConnection.DNSSuffix) { $SuffixResult += $VPNConnection.DNSSuffix } IF ($GlobalDNSSuffixes.Count -ne 0) { $SuffixResult += $GlobalDNSSuffixes } ### Results IF (($SuffixResult -is [array] -and $SuffixResult.Count -gt 0) -or ($SuffixResult -isnot [array] -and $SuffixResult.Length -gt 2)) { $Results += AddResults -Category "$($VPNConnection.Name)" -Item $VPNConnection.Type -ItemDetails "DNS Suffix" -Result ($SuffixResult -join ", ") -AlertLevel "Normal" -ResultDetails $NoIssuesFound } ELSE { FOREACH ($Suffix in $NetworkConnection.DNSSuffix) { $Results += AddResults -Category "$($VPNConnection.Name)" -Item $VPNConnection.Type -ItemDetails "DNS Suffix" -Result "[None]" -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } } ### Connection Profile IF ($True) { $Results += AddResults -Category "$($VPNConnection.Name)" -Item $VPNConnection.Type -ItemDetails "Connection Profile" -Result $VPNConnection.ConnectionProfile -AlertLevel "Normal" -ResultDetails $NoIssuesFound } } } } ################### ####### End ####### ################### Write-Progress -ID 13 -Activity "Checking All" -Status "100% - Complete" -PercentComplete 100 -Completed IF ($PSVersionTable.PSVersion.Major -ge 7) { RETURN $Results | Select-Object Category, Item, ItemDetails, Result, AlertLevel, ResultDetails | Format-Table -GroupBy Category | Out-String -Stream | ForEach-Object { IF ($_ -match 'Warning') {"$($PSStyle.Foreground.FromRgb(200,200,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -match 'Category:') {"$($PSStyle.Foreground.FromRgb(255,255,255))$_$($PSStyle.Reset)" } ELSEIF ($_ -like '*----*') {"$($PSStyle.Foreground.FromRgb(255,255,255))$_$($PSStyle.Reset)" } ELSEIF ($_ -match 'AlertLevel') {"$($PSStyle.Foreground.FromRgb(255,255,255))$_$($PSStyle.Reset)" } ELSEIF ($_ -match 'Error') {"$($PSStyle.Foreground.FromRgb(200,100,0))$_$($PSStyle.Reset)" } ELSEIF ($_ -match 'Critical') {"$($PSStyle.Foreground.FromRgb(225,0,0))$_$($PSStyle.Reset)" } ELSE {"$($PSStyle.Foreground.FromRgb(255,255,255))$_$($PSStyle.Reset)" } } } ELSE { RETURN $Results | Select-Object Category, Item, ItemDetails, Result, AlertLevel, ResultDetails | Format-Table -GroupBy Category | Out-String -Stream | ForEach-Object { $OutA = IF ($_ -match 'Warning') {@{'ForegroundColor' = 'Yellow' }} ELSEIF ($_ -match 'Category:') {@{'ForegroundColor' = 'White' }} ELSEIF ($_ -like '*----*') {@{'ForegroundColor' = 'White' }} ELSEIF ($_ -match 'AlertLevel') {@{'ForegroundColor' = 'White' }} ELSEIF ($_ -match 'Error') {@{'ForegroundColor' = 'Magenta' }} ELSEIF ($_ -match 'Critical') {@{'ForegroundColor' = 'Red' }} ELSE {@{'ForegroundColor' = 'White' }} Write-Host @OutA $_ } } } New-Alias -Name Diagnose-Computer -Value Debug-Computer |