#Requires -Version 5.1 <# .SYNOPSIS Help Wizards IT Health Assessment .DESCRIPTION Collects device health data from this machine and discovers other devices on the local network. Generates a ZIP containing a JSON data file and an HTML report. Email the ZIP to dispatch@helpwizards.com. .NOTES Run as Administrator for full data collection. Version: 1.0 | Help Wizards | Columbus, Ohio | (614) 291-4357 #> Set-StrictMode -Off $ErrorActionPreference = 'SilentlyContinue' Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing # ============================================================ # CONFIG # ============================================================ $HW_EMAIL = 'dispatch@helpwizards.com' $HW_NAME = 'Help Wizards' $HW_PHONE = '(614) 291-4357' $TOOL_VER = '1.0' $SFTP_HOST = 'helpwizards.com' $SFTP_PORT = 2222 $SFTP_USER = 'audit-intake' $SFTP_REMOTE = 'incoming' # Embedded deploy key (read-only upload access only) $SFTP_KEY = @' -----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW QyNTUxOQAAACAjn2o/brkw3eB1g320gzBdc9+R5zA9jpcNEZQfhK5ENwAAAKB4N4uXeDeL lwAAAAtzc2gtZWQyNTUxOQAAACAjn2o/brkw3eB1g320gzBdc9+R5zA9jpcNEZQfhK5ENw AAAEBep6oq8R9PZnADaU6LRqKIMQYks7I4zWjE84gt7gtPzSOfaj9uuTDd4HWDfbSDMF1z 35HnMD2Olw0RlB+ErkQ3AAAAGGh3LWF1ZGl0QGhlbHB3aXphcmRzLmNvbQECAwQF -----END OPENSSH PRIVATE KEY----- '@ # ============================================================ # GUI # ============================================================ $form = New-Object System.Windows.Forms.Form $form.Text = 'Help Wizards IT Health Assessment' $form.Size = New-Object System.Drawing.Size(520, 440) $form.StartPosition = 'CenterScreen' $form.FormBorderStyle = 'FixedSingle' $form.MaximizeBox = $false $form.BackColor = [System.Drawing.Color]::FromArgb(15, 23, 42) function New-Label($text, $x, $y, $w, $h, $size=10, $bold=$false, $color='White') { $l = New-Object System.Windows.Forms.Label $l.Text = $text $l.Location = New-Object System.Drawing.Point($x, $y) $l.Size = New-Object System.Drawing.Size($w, $h) $l.ForeColor = [System.Drawing.Color]::FromName($color) $style = if ($bold) { [System.Drawing.FontStyle]::Bold } else { [System.Drawing.FontStyle]::Regular } $l.Font = New-Object System.Drawing.Font('Segoe UI', $size, $style) $l.BackColor = [System.Drawing.Color]::Transparent return $l } # Header $headerPanel = New-Object System.Windows.Forms.Panel $headerPanel.Location = New-Object System.Drawing.Point(0, 0) $headerPanel.Size = New-Object System.Drawing.Size(520, 70) $headerPanel.BackColor = [System.Drawing.Color]::FromArgb(30, 58, 95) $form.Controls.Add($headerPanel) $lblTitle = New-Label 'Help Wizards' 20 12 300 32 16 $true 'White' $headerPanel.Controls.Add($lblTitle) $lblSub = New-Label 'IT Health Assessment Tool' 20 40 300 22 9 $false $lblSub.ForeColor = [System.Drawing.Color]::FromArgb(148, 163, 184) $headerPanel.Controls.Add($lblSub) $lblVer = New-Label "v$TOOL_VER" 440 48 60 18 8 $false $lblVer.ForeColor = [System.Drawing.Color]::FromArgb(100, 116, 139) $headerPanel.Controls.Add($lblVer) # Description $lblDesc = New-Label "This tool scans your computers and network devices to assess IT health.`nResults are saved to a ZIP file — email it to $HW_NAME and we'll`nprepare a free assessment with recommendations." 20 85 480 56 9 $false $lblDesc.ForeColor = [System.Drawing.Color]::FromArgb(148, 163, 184) $form.Controls.Add($lblDesc) # Status label $lblStatus = New-Label 'Ready to scan. Click Start to begin.' 20 148 480 20 9 $false $lblStatus.ForeColor = [System.Drawing.Color]::FromArgb(148, 163, 184) $form.Controls.Add($lblStatus) # Progress bar $progress = New-Object System.Windows.Forms.ProgressBar $progress.Location = New-Object System.Drawing.Point(20, 172) $progress.Size = New-Object System.Drawing.Size(475, 14) $progress.Style = 'Continuous' $progress.BackColor = [System.Drawing.Color]::FromArgb(30, 41, 59) $progress.ForeColor = [System.Drawing.Color]::FromArgb(34, 197, 94) $progress.Visible = $false $form.Controls.Add($progress) # Results box $txtResults = New-Object System.Windows.Forms.RichTextBox $txtResults.Location = New-Object System.Drawing.Point(20, 196) $txtResults.Size = New-Object System.Drawing.Size(475, 155) $txtResults.BackColor = [System.Drawing.Color]::FromArgb(15, 23, 42) $txtResults.ForeColor = [System.Drawing.Color]::FromArgb(100, 116, 139) $txtResults.Font = New-Object System.Drawing.Font('Consolas', 8) $txtResults.ReadOnly = $true $txtResults.BorderStyle = 'None' $form.Controls.Add($txtResults) # Buttons $btnStart = New-Object System.Windows.Forms.Button $btnStart.Location = New-Object System.Drawing.Point(20, 365) $btnStart.Size = New-Object System.Drawing.Size(120, 36) $btnStart.Text = 'Start Scan' $btnStart.FlatStyle = 'Flat' $btnStart.BackColor = [System.Drawing.Color]::FromArgb(34, 197, 94) $btnStart.ForeColor = [System.Drawing.Color]::FromArgb(15, 23, 42) $btnStart.Font = New-Object System.Drawing.Font('Segoe UI', 10, [System.Drawing.FontStyle]::Bold) $btnStart.FlatAppearance.BorderSize = 0 $form.Controls.Add($btnStart) # Save and Email buttons hidden — only shown if SFTP fails $btnSave = New-Object System.Windows.Forms.Button $btnSave.Location = New-Object System.Drawing.Point(155, 365) $btnSave.Size = New-Object System.Drawing.Size(140, 36) $btnSave.Text = 'Save Report ZIP' $btnSave.FlatStyle = 'Flat' $btnSave.BackColor = [System.Drawing.Color]::FromArgb(30, 64, 175) $btnSave.ForeColor = [System.Drawing.Color]::White $btnSave.Font = New-Object System.Drawing.Font('Segoe UI', 10, [System.Drawing.FontStyle]::Bold) $btnSave.FlatAppearance.BorderSize = 0 $btnSave.Visible = $false $form.Controls.Add($btnSave) $btnEmail = New-Object System.Windows.Forms.Button $btnEmail.Location = New-Object System.Drawing.Point(308, 365) $btnEmail.Size = New-Object System.Drawing.Size(187, 36) $btnEmail.Text = 'Email Instead' $btnEmail.FlatStyle = 'Flat' $btnEmail.BackColor = [System.Drawing.Color]::FromArgb(30, 58, 95) $btnEmail.ForeColor = [System.Drawing.Color]::FromArgb(148, 163, 184) $btnEmail.Font = New-Object System.Drawing.Font('Segoe UI', 9) $btnEmail.FlatAppearance.BorderSize = 0 $btnEmail.Visible = $false $form.Controls.Add($btnEmail) $script:auditData = $null $script:zipPath = $null function Write-Log($msg, $color='Gray') { $txtResults.SelectionStart = $txtResults.TextLength $txtResults.SelectionColor = [System.Drawing.Color]::FromName($color) $txtResults.AppendText("$msg`n") $txtResults.ScrollToCaret() [System.Windows.Forms.Application]::DoEvents() } function Set-Status($msg) { $lblStatus.Text = $msg [System.Windows.Forms.Application]::DoEvents() } function Step-Progress($pct) { $progress.Value = [Math]::Min($pct, 100) [System.Windows.Forms.Application]::DoEvents() } # ============================================================ # DATA COLLECTION # ============================================================ function Get-SystemInfo { Set-Status 'Collecting system information...' Write-Log ' System info...' 'Gray' $cs = Get-WmiObject Win32_ComputerSystem $os = Get-WmiObject Win32_OperatingSystem $bios= Get-WmiObject Win32_BIOS $cpu = Get-WmiObject Win32_Processor | Select-Object -First 1 $lastBoot = $os.ConvertToDateTime($os.LastBootUpTime) $uptime = (Get-Date) - $lastBoot $installDate = try { $os.ConvertToDateTime($os.InstallDate).ToString('yyyy-MM-dd') } catch { '' } # Pending reboot detection $pendingReboot = $false $rebootReasons = @() if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') { $pendingReboot = $true; $rebootReasons += 'Windows Update' } if (Test-Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations') { $pendingReboot = $true; $rebootReasons += 'Pending file operations' } if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') { $pendingReboot = $true; $rebootReasons += 'Component servicing' } return @{ computer_name = $env:COMPUTERNAME domain = $cs.Domain domain_joined = $cs.PartOfDomain manufacturer = $cs.Manufacturer model = $cs.Model os_name = $os.Caption os_version = $os.Version os_build = $os.BuildNumber os_arch = $os.OSArchitecture install_date = $installDate last_boot = $lastBoot.ToString('yyyy-MM-dd HH:mm') uptime_days = [Math]::Round($uptime.TotalDays, 1) pending_reboot = $pendingReboot reboot_reasons = $rebootReasons serial_number = $bios.SerialNumber bios_version = $bios.SMBIOSBIOSVersion cpu_name = $cpu.Name.Trim() cpu_cores = $cpu.NumberOfCores cpu_threads = $cpu.NumberOfLogicalProcessors ram_gb = [Math]::Round($cs.TotalPhysicalMemory / 1GB, 1) scan_time = (Get-Date).ToString('yyyy-MM-ddTHH:mm:ss') tool_version = $TOOL_VER } } function Get-DiskInfo { Set-Status 'Checking disk drives...' Write-Log ' Disk health...' 'Gray' $disks = Get-WmiObject Win32_LogicalDisk | Where-Object { $_.DriveType -eq 3 } return $disks | ForEach-Object { $pct = if ($_.Size -gt 0) { [Math]::Round(($_.Size - $_.FreeSpace) / $_.Size * 100, 1) } else { 0 } @{ drive = $_.DeviceID label = $_.VolumeName size_gb = [Math]::Round($_.Size / 1GB, 1) free_gb = [Math]::Round($_.FreeSpace / 1GB, 1) used_pct = $pct status = if ($pct -gt 90) { 'CRITICAL' } elseif ($pct -gt 80) { 'WARNING' } else { 'OK' } } } } function Get-PatchInfo { Set-Status 'Checking Windows Update status...' Write-Log ' Windows patches...' 'Gray' # Pending updates via WUA COM $pendingUpdates = @() $pendingCount = 0 try { $updateSession = New-Object -ComObject Microsoft.Update.Session $updateSearcher = $updateSession.CreateUpdateSearcher() $searchResult = $updateSearcher.Search('IsInstalled=0 AND IsHidden=0') $pendingCount = $searchResult.Updates.Count $pendingUpdates = $searchResult.Updates | ForEach-Object { @{ title = $_.Title; severity = $_.MsrcSeverity; kb = ($_.KBArticleIDs -join ',') } } | Select-Object -First 20 } catch {} # Last successful update check $lastCheck = '' try { $ua = New-Object -ComObject Microsoft.Update.AutoUpdate $lastCheck = $ua.Results.LastSearchSuccessDate.ToString('yyyy-MM-dd HH:mm') } catch {} # Recent installed hotfixes $recentPatches = Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 5 | ForEach-Object { @{ kb = $_.HotFixID; installed = "$($_.InstalledOn)" } } return @{ pending_count = $pendingCount pending_updates = $pendingUpdates last_check = $lastCheck recent_patches = $recentPatches status = if ($pendingCount -gt 10) { 'CRITICAL' } elseif ($pendingCount -gt 0) { 'NEEDS_ATTENTION' } else { 'HEALTHY' } } } function Get-AVStatus { Set-Status 'Checking antivirus...' Write-Log ' Antivirus status...' 'Gray' $avProducts = @() try { $avProducts = Get-WmiObject -Namespace 'root\SecurityCenter2' -Class AntiVirusProduct | ForEach-Object { $state = $_.productState.ToString('X6') @{ name = $_.displayName enabled = ($state.Substring(2,2) -eq '10') up_to_date = ($state.Substring(4,2) -eq '00') product_state= $_.productState } } } catch {} $fwProfiles = @() try { $fwProfiles = Get-NetFirewallProfile | ForEach-Object { @{ profile = $_.Name; enabled = $_.Enabled } } } catch {} $defenderStatus = @{} try { $mp = Get-MpComputerStatus $defenderStatus = @{ enabled = $mp.AntivirusEnabled real_time_protection = $mp.RealTimeProtectionEnabled definitions_updated = $mp.AntivirusSignatureLastUpdated.ToString('yyyy-MM-dd') definitions_age_days = ([int]((Get-Date) - $mp.AntivirusSignatureLastUpdated).TotalDays) quick_scan_age_days = ([int]((Get-Date) - $mp.QuickScanEndTime).TotalDays) } } catch {} return @{ av_products = $avProducts windows_defender = $defenderStatus firewall = $fwProfiles status = if (-not $avProducts -and -not $defenderStatus.enabled) { 'CRITICAL' } else { 'OK' } } } function Get-SecurityInfo { Set-Status 'Checking security settings...' Write-Log ' Security settings...' 'Gray' # BitLocker $bitlocker = @() try { $bitlocker = Get-BitLockerVolume | ForEach-Object { @{ drive = $_.MountPoint; status = $_.ProtectionStatus.ToString(); encryption = $_.EncryptionMethod.ToString() } } } catch {} # Local admins $localAdmins = @() try { $localAdmins = (Get-LocalGroupMember -Group 'Administrators' -ErrorAction SilentlyContinue) | ForEach-Object { $_.Name } } catch {} # Local users $localUsers = @() try { $localUsers = Get-LocalUser | ForEach-Object { @{ name = $_.Name; enabled = $_.Enabled; last_logon = "$($_.LastLogon)" } } } catch {} # RDP enabled $rdpEnabled = $false try { $rdp = Get-ItemProperty 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections $rdpEnabled = ($rdp.fDenyTSConnections -eq 0) } catch {} # UAC $uacEnabled = $true try { $uac = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' -Name EnableLUA $uacEnabled = ($uac.EnableLUA -eq 1) } catch {} return @{ bitlocker = $bitlocker local_admins = $localAdmins local_users = $localUsers rdp_enabled = $rdpEnabled uac_enabled = $uacEnabled } } # ============================================================ # ENRICHED DATA COLLECTION ADDITIONS # ============================================================ function Get-InstalledSoftwareFull { Set-Status 'Cataloging all installed software...' Write-Log ' Software inventory (all sources)...' 'Gray' $paths = @( 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' ) $seen = @{} $software = @() foreach ($path in $paths) { Get-ItemProperty $path -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -and $_.DisplayName.Trim() } | ForEach-Object { $key = ($_.DisplayName.Trim() + '|' + ($_.DisplayVersion ?? '')).ToLower() if (-not $seen[$key]) { $seen[$key] = $true $software += @{ name = $_.DisplayName.Trim() version = $_.DisplayVersion ?? '' publisher = $_.Publisher ?? '' installed = $_.InstallDate ?? '' source = 'registry' } } } } # Microsoft Store / AppX packages try { Get-AppxPackage -ErrorAction SilentlyContinue | Where-Object { $_.IsFramework -eq $false } | ForEach-Object { $software += @{ name = $_.Name version = $_.Version publisher = $_.Publisher installed = '' source = 'store' } } } catch {} Write-Log " Found $($software.Count) applications" 'Gray' return $software } function Get-DotNetVersions { Set-Status 'Checking .NET versions...' $versions = @() # .NET Framework try { Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse -ErrorAction SilentlyContinue | Get-ItemProperty -Name Version, Release -ErrorAction SilentlyContinue | Where-Object { $_.Version } | ForEach-Object { $versions += @{ type = 'Framework'; version = $_.Version; release = $_.Release } } } catch {} # .NET Core / .NET 5+ try { $dotnet = & 'dotnet' '--list-runtimes' 2>$null if ($dotnet) { $dotnet | ForEach-Object { if ($_ -match 'Microsoft\.NETCore\.App\s+([\d\.]+)') { $versions += @{ type = 'Core/5+'; version = $matches[1]; release = 0 } } } } } catch {} return $versions } function Get-OfficeInfo { Set-Status 'Checking Microsoft Office...' $info = @{ installed = $false; version = ''; channel = ''; apps = @() } try { # Office version from registry $officeKeys = @( 'HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration', 'HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\InstallRoot' ) foreach ($key in $officeKeys) { $reg = Get-ItemProperty $key -ErrorAction SilentlyContinue if ($reg) { $info.installed = $true if ($reg.VersionToReport) { $info.version = $reg.VersionToReport } if ($reg.CDNBaseUrl) { $info.channel = switch -Wildcard ($reg.CDNBaseUrl) { '*CurrentChannel*' { 'Current Channel' } '*MonthlyEnterprise*' { 'Monthly Enterprise' } '*SemiAnnual*' { 'Semi-Annual Enterprise' } '*PerpetualVL2021*' { 'Perpetual 2021' } '*PerpetualVL2024*' { 'Perpetual 2024' } default { $reg.CDNBaseUrl } } } break } } # Installed Office apps $appPaths = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\InstallRoot' -ErrorAction SilentlyContinue if ($appPaths) { $info.apps += 'Office 16.x' } } catch {} return $info } function Get-BrowserExtensions { Set-Status 'Checking browser extensions...' $extensions = @() $profiles = @( @{ browser = 'Chrome'; path = "$env:LOCALAPPDATA\Google\Chrome\User Data" }, @{ browser = 'Edge'; path = "$env:LOCALAPPDATA\Microsoft\Edge\User Data" } ) foreach ($b in $profiles) { if (-not (Test-Path $b.path)) { continue } Get-ChildItem "$($b.path)\*\Extensions" -Directory -ErrorAction SilentlyContinue | Get-ChildItem -Directory -ErrorAction SilentlyContinue | ForEach-Object { $extId = $_.Name Get-ChildItem $_.FullName -Directory -ErrorAction SilentlyContinue | Select-Object -First 1 | ForEach-Object { $manifest = Join-Path $_.FullName 'manifest.json' if (Test-Path $manifest) { try { $m = Get-Content $manifest -Raw | ConvertFrom-Json $extensions += @{ browser = $b.browser id = $extId name = $m.name ?? $extId version = $m.version ?? '' } } catch {} } } } } return $extensions } function Get-PatchHistory { Set-Status 'Checking patch history...' $history = @() try { $session = New-Object -ComObject Microsoft.Update.Session $searcher = $session.CreateUpdateSearcher() $count = $searcher.GetTotalHistoryCount() $take = [Math]::Min($count, 20) if ($take -gt 0) { $searcher.QueryHistory(0, $take) | ForEach-Object { $history += @{ title = $_.Title date = $_.Date.ToString('yyyy-MM-dd') result = $_.ResultCode # 2=succeeded, 3=succeeded with errors, 4=failed kb = if ($_.Title -match 'KB(\d+)') { "KB$($matches[1])" } else { '' } } } } } catch {} return $history } function Get-SecurityExtended { Set-Status 'Checking extended security settings...' $result = @{ tpm_version = '' tpm_enabled = $false secure_boot = $false defender_exclusions = @() shared_folders = @() failed_logins_24h = 0 last_failed_login = '' } # TPM try { $tpm = Get-WmiObject -Namespace 'root\cimv2\Security\MicrosoftTpm' -Class Win32_Tpm -ErrorAction Stop if ($tpm) { $result.tpm_enabled = $tpm.IsEnabled_InitialValue $result.tpm_version = $tpm.SpecVersion ?? '' } } catch {} # Secure Boot try { $result.secure_boot = Confirm-SecureBootUEFI -ErrorAction SilentlyContinue } catch { $result.secure_boot = $false } # Defender exclusions try { $excl = Get-MpPreference -ErrorAction SilentlyContinue if ($excl) { $result.defender_exclusions = @($excl.ExclusionPath | Where-Object { $_ }) + @($excl.ExclusionExtension | Where-Object { $_ }) } } catch {} # Shared folders try { $result.shared_folders = Get-SmbShare -ErrorAction SilentlyContinue | Where-Object { $_.Name -notlike '*$' } | ForEach-Object { @{ name = $_.Name; path = $_.Path; description = $_.Description } } } catch {} # Failed logins last 24h try { $since = (Get-Date).AddHours(-24) $events = Get-WinEvent -FilterHashtable @{ LogName = 'Security' Id = 4625 StartTime = $since } -MaxEvents 50 -ErrorAction SilentlyContinue $result.failed_logins_24h = ($events | Measure-Object).Count if ($events) { $result.last_failed_login = $events[0].TimeCreated.ToString('yyyy-MM-dd HH:mm') } } catch {} return $result } function Get-HardwareExtended { Set-Status 'Checking hardware details...' $result = @{ battery_pct = $null battery_status = '' gpu = '' chassis_type = '' total_storage_gb = 0 } # Battery try { $bat = Get-WmiObject Win32_Battery -ErrorAction SilentlyContinue | Select-Object -First 1 if ($bat) { $result.battery_pct = $bat.EstimatedChargeRemaining $result.battery_status = $bat.Status } } catch {} # GPU try { $gpu = Get-WmiObject Win32_VideoController -ErrorAction SilentlyContinue | Select-Object -First 1 if ($gpu) { $result.gpu = $gpu.Name } } catch {} # Chassis type try { $chassis = (Get-WmiObject Win32_SystemEnclosure -ErrorAction SilentlyContinue).ChassisTypes $result.chassis_type = switch ($chassis | Select-Object -First 1) { 9 { 'Laptop' }; 10 { 'Notebook' }; 14 { 'Sub-Notebook' } 3 { 'Desktop' }; 4 { 'Desktop' }; 6 { 'Mini Tower' }; 7 { 'Tower' } default { 'Unknown' } } } catch {} return $result } function Get-NetworkInfo { Set-Status 'Getting network information...' Write-Log ' Network adapters...' 'Gray' $adapters = Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.InterfaceAlias -notlike '*Loopback*' -and $_.IPAddress -notlike '169.*' } | ForEach-Object { $adapter = Get-NetAdapter -InterfaceIndex $_.InterfaceIndex -ErrorAction SilentlyContinue @{ name = $_.InterfaceAlias ip = $_.IPAddress prefix = $_.PrefixLength mac = $adapter.MacAddress link_speed = "$($adapter.LinkSpeed)" status = "$($adapter.Status)" } } return $adapters } function Get-NetworkDevices { param([array]$adapters) # Network scan skipped — just return local adapter info as the device list Set-Status 'Noting network configuration...' Write-Log ' Network info noted.' 'Gray' return @() } # ============================================================ # HEALTH SCORING # ============================================================ function Get-HealthScore { param($data) $issues = @() $score = 100 # OS checks $os = $data.system.os_name if ($os -match 'Windows 10') { $issues += @{ severity='WARNING'; category='OS'; msg='Windows 10 — End of Support October 2025' }; $score -= 10 } if ($os -match 'Server 2012') { $issues += @{ severity='CRITICAL'; category='OS'; msg='Windows Server 2012 — End of Support (no updates)' }; $score -= 25 } if ($os -match 'Server 2016') { $issues += @{ severity='WARNING'; category='OS'; msg='Windows Server 2016 — End of Support January 2027' }; $score -= 10 } # Patches $pc = $data.patches.pending_count if ($pc -gt 10) { $issues += @{ severity='CRITICAL'; category='Patches'; msg="$pc pending Windows updates" }; $score -= 20 } elseif ($pc -gt 0){ $issues += @{ severity='WARNING'; category='Patches'; msg="$pc pending Windows updates" }; $score -= 10 } # Pending reboot if ($data.system.pending_reboot) { $issues += @{ severity='WARNING'; category='Reboot'; msg="Pending reboot ($($data.system.reboot_reasons -join ', '))" }; $score -= 5 } # Disk foreach ($d in $data.disks) { if ($d.used_pct -gt 90) { $issues += @{ severity='CRITICAL'; category='Disk'; msg="Drive $($d.drive): $($d.used_pct)% full" }; $score -= 15 } elseif ($d.used_pct -gt 80) { $issues += @{ severity='WARNING'; category='Disk'; msg="Drive $($d.drive): $($d.used_pct)% full" }; $score -= 5 } } # RAM if ($data.system.ram_gb -lt 4) { $issues += @{ severity='CRITICAL'; category='Hardware'; msg="Only $($data.system.ram_gb) GB RAM" }; $score -= 10 } elseif ($data.system.ram_gb -lt 8) { $issues += @{ severity='WARNING'; category='Hardware'; msg="$($data.system.ram_gb) GB RAM (8 GB recommended)" }; $score -= 5 } # AV if ($data.security_av.status -eq 'CRITICAL') { $issues += @{ severity='CRITICAL'; category='Security'; msg='No active antivirus detected' }; $score -= 20 } if ($data.security_av.windows_defender.definitions_age_days -gt 7) { $issues += @{ severity='WARNING'; category='Security'; msg="Defender definitions $($data.security_av.windows_defender.definitions_age_days) days old" }; $score -= 5 } # BitLocker $encrypted = $data.security_settings.bitlocker | Where-Object { $_.status -eq 'On' } if (-not $encrypted) { $issues += @{ severity='WARNING'; category='Security'; msg='Disk encryption (BitLocker) not enabled' }; $score -= 5 } # UAC if (-not $data.security_settings.uac_enabled) { $issues += @{ severity='WARNING'; category='Security'; msg='User Account Control (UAC) disabled' }; $score -= 5 } $score = [Math]::Max(0, $score) $overall = if ($score -ge 80) { 'HEALTHY' } elseif ($score -ge 50) { 'NEEDS_ATTENTION' } else { 'UNHEALTHY' } return @{ score = $score; overall = $overall; issues = $issues } } # ============================================================ # HTML REPORT # ============================================================ function New-HTMLReport { param($data, $health) $scoreColor = switch ($health.overall) { 'HEALTHY' { '#22c55e' } 'NEEDS_ATTENTION' { '#f97316' } default { '#ef4444' } } $issueRows = ($health.issues | ForEach-Object { $c = if ($_.severity -eq 'CRITICAL') { '#ef4444' } else { '#f97316' } "$($_.severity)$($_.category)$($_.msg)" }) -join '' $diskRows = ($data.disks | ForEach-Object { $c = if ($_.used_pct -gt 90) { '#ef4444' } elseif ($_.used_pct -gt 80) { '#f97316' } else { '#22c55e' } "$($_.drive)$($_.label)$($_.size_gb) GB$($_.free_gb) GB$($_.used_pct)%" }) -join '' $netRows = ($data.network_devices | Select-Object -First 50 | ForEach-Object { "$($_.ip)$($_.hostname)$($_.os)" }) -join '' $avName = if ($data.security_av.av_products) { ($data.security_av.av_products | ForEach-Object { $_.name }) -join ', ' } else { 'None detected' } return @" IT Health Assessment — $($data.system.computer_name)

IT Health Assessment

$($data.system.computer_name)  ·  $($data.system.os_name)  ·  Scanned $($data.system.scan_time)
$($health.score)
$($health.overall.Replace('_', ' '))
Health score out of 100  ·  $($health.issues.Count) issue(s) found
$($data.network_devices.Count) device(s) found on local network
$(if ($health.issues.Count -gt 0) { "

⚠️ Issues Found ($($health.issues.Count))

$issueRows
SeverityCategoryIssue
" })

System Information

Computer Name
$($data.system.computer_name)
Operating System
$($data.system.os_name)
OS Build
$($data.system.os_version) ($($data.system.os_arch))
Domain
$(if ($data.system.domain_joined) { $data.system.domain } else { 'Workgroup' })
Manufacturer / Model
$($data.system.manufacturer) $($data.system.model)
CPU
$($data.system.cpu_name)
RAM
$($data.system.ram_gb) GB
Last Boot
$($data.system.last_boot) ($($data.system.uptime_days) days up)
Pending Reboot
$(if ($data.system.pending_reboot) { '⚠️ YES' } else { '✅ No' })
Serial Number
$($data.system.serial_number)

Disk Drives

$diskRows
DriveLabelSizeFreeUsed

Patches & Updates

Pending Updates
$($data.patches.pending_count)
Last Checked
$($data.patches.last_check)

Security

Antivirus
$avName
Windows Firewall
$(($data.security_av.firewall | Where-Object { $_.enabled } | ForEach-Object { $_.profile }) -join ', ')
BitLocker
$(if ($data.security_settings.bitlocker) { ($data.security_settings.bitlocker | ForEach-Object { "$($_.drive) $($_.status)" }) -join ', ' } else { 'Not configured' })
UAC
$(if ($data.security_settings.uac_enabled) { 'Enabled' } else { '⚠️ Disabled' })
RDP
$(if ($data.security_settings.rdp_enabled) { 'Enabled' } else { 'Disabled' })
Local Admins
$($data.security_settings.local_admins -join ', ')
$(if ($data.network_devices.Count -gt 0) { "

Network Devices ($($data.network_devices.Count) found)

$netRows
IP AddressHostnameOS
" })
"@ } # ============================================================ # MAIN SCAN LOGIC # ============================================================ $btnStart.Add_Click({ $btnStart.Enabled = $false $btnStart.Text = 'Scanning...' $btnSave.Enabled = $false $btnEmail.Enabled = $false $txtResults.Clear() $progress.Visible = $true $progress.Value = 0 try { Write-Log 'Starting Help Wizards IT Health Assessment...' 'White' Write-Log '' 'Gray' Step-Progress 5 $sysInfo = Get-SystemInfo Write-Log " Computer: $($sysInfo.computer_name) | OS: $($sysInfo.os_name)" 'White' Step-Progress 20 $diskInfo = Get-DiskInfo Step-Progress 35 $patchInfo = Get-PatchInfo Write-Log " Pending updates: $($patchInfo.pending_count)" 'White' Step-Progress 50 $avInfo = Get-AVStatus Step-Progress 60 $secInfo = Get-SecurityInfo Step-Progress 65 $swInfo = Get-InstalledSoftwareFull Write-Log " Installed software: $($swInfo.Count) items" 'White' Step-Progress 72 $dotnetInfo = Get-DotNetVersions $officeInfo = Get-OfficeInfo Write-Log " Office: $($officeInfo.version) $($officeInfo.channel)" 'Gray' Step-Progress 78 $browserExts = Get-BrowserExtensions Write-Log " Browser extensions: $($browserExts.Count)" 'Gray' Step-Progress 82 $patchHistory = Get-PatchHistory Write-Log " Patch history: $($patchHistory.Count) entries" 'Gray' Step-Progress 86 $secExtended = Get-SecurityExtended Write-Log " TPM: $($secExtended.tpm_version) | Secure Boot: $($secExtended.secure_boot)" 'Gray' Step-Progress 90 $hwExtended = Get-HardwareExtended if ($hwExtended.battery_pct -ne $null) { Write-Log " Battery: $($hwExtended.battery_pct)%" 'Gray' } $netAdapters = Get-NetworkInfo $netDevices = Get-NetworkDevices -adapters $netAdapters Step-Progress 95 # Assemble full payload $script:auditData = @{ system = $sysInfo disks = $diskInfo patches = $patchInfo patch_history = $patchHistory security_av = $avInfo security_settings = $secInfo security_extended = $secExtended hardware_extended = $hwExtended software = $swInfo dotnet = $dotnetInfo office = $officeInfo browser_extensions= $browserExts network_adapters = $netAdapters network_devices = $netDevices } $health = Get-HealthScore -data $script:auditData $script:auditData.health = $health Step-Progress 96 Write-Log '' 'Gray' Write-Log "HEALTH SCORE: $($health.score)/100 — $($health.overall)" $( if ($health.overall -eq 'HEALTHY') { 'Green' } elseif ($health.overall -eq 'NEEDS_ATTENTION') { 'Yellow' } else { 'Red' } ) if ($health.issues.Count -gt 0) { Write-Log "Issues found:" 'White' foreach ($issue in $health.issues) { $c = if ($issue.severity -eq 'CRITICAL') { 'Red' } else { 'Yellow' } Write-Log " [$($issue.severity)] $($issue.category): $($issue.msg)" $c } } Step-Progress 100 Set-Status 'Scan complete. Save and email the ZIP file.' Write-Log '' 'Gray' Write-Log "Done! Click 'Save Report ZIP' then email the file to us." 'Green' # Auto-save and submit Set-Status 'Submitting results to Help Wizards...' Write-Log '' 'Gray' Write-Log 'Submitting your results...' 'White' $autoZipName = "HW-Audit-$($sysInfo.computer_name)-$(Get-Date -Format 'yyyyMMdd').zip" $autoZipPath = Join-Path $env:TEMP $autoZipName $tmpDir2 = Join-Path $env:TEMP "HWAudit-out-$(Get-Random)" New-Item -ItemType Directory -Path $tmpDir2 -Force | Out-Null try { $script:auditData | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $tmpDir2 'audit-results.json') -Encoding UTF8 if (Test-Path $autoZipPath) { Remove-Item $autoZipPath -Force } Compress-Archive -Path "$tmpDir2\*" -DestinationPath $autoZipPath } finally { Remove-Item $tmpDir2 -Recurse -Force -ErrorAction SilentlyContinue } $sftp = Submit-Via-SFTP -ZipPath $autoZipPath Remove-Item $autoZipPath -Force -ErrorAction SilentlyContinue if ($sftp.success) { Write-Log 'Submitted successfully!' 'Green' Set-Status 'Done! Results sent to Help Wizards.' [System.Windows.Forms.Application]::DoEvents() Start-Sleep -Milliseconds 800 [System.Windows.Forms.MessageBox]::Show( "Thank you! Your IT assessment has been submitted to Help Wizards.`n`nScore: $($health.score)/100 — $($health.overall.Replace('_',' '))`n`nWe will review your results and reach out within one business day.`n`n$HW_PHONE`nhelpwizards.com", 'Help Wizards — Submitted', [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information ) | Out-Null $form.Close() } else { Write-Log 'Auto-submit failed. Please email results manually.' 'Yellow' Set-Status 'Submit failed — see options below.' $btnSave.Visible = $true $btnEmail.Visible = $true } } catch { Write-Log "ERROR: $_" 'Red' Set-Status 'Scan error — see details above.' } $btnStart.Enabled = $true $btnStart.Text = 'Start Scan' }) # ============================================================ # SAVE ZIP # ============================================================ $btnSave.Add_Click({ $saveDialog = New-Object System.Windows.Forms.SaveFileDialog $saveDialog.Filter = 'ZIP Archive|*.zip' $saveDialog.FileName = "HW-Audit-$($script:auditData.system.computer_name)-$(Get-Date -Format 'yyyyMMdd')" $saveDialog.Title = 'Save IT Assessment ZIP' if ($saveDialog.ShowDialog() -eq 'OK') { $script:zipPath = $saveDialog.FileName $tmpDir = Join-Path $env:TEMP "HWAudit-$(Get-Random)" New-Item -ItemType Directory -Path $tmpDir -Force | Out-Null try { # JSON payload $jsonPath = Join-Path $tmpDir 'audit-results.json' $script:auditData | ConvertTo-Json -Depth 10 | Set-Content $jsonPath -Encoding UTF8 # HTML report $htmlPath = Join-Path $tmpDir 'audit-report.html' $html = New-HTMLReport -data $script:auditData -health $script:auditData.health $html | Set-Content $htmlPath -Encoding UTF8 # README $readmePath = Join-Path $tmpDir 'README.txt' @" Help Wizards IT Health Assessment ================================== Computer: $($script:auditData.system.computer_name) Scanned: $($script:auditData.system.scan_time) Score: $($script:auditData.health.score)/100 ($($script:auditData.health.overall)) FILES INCLUDED: audit-report.html Open in any browser to view the full report audit-results.json Raw data for Help Wizards analysis HOW TO SUBMIT: Email this ZIP file to: $HW_EMAIL Subject: IT Assessment — $($script:auditData.system.computer_name) Questions? Call $HW_PHONE or visit helpwizards.com "@ | Set-Content $readmePath -Encoding UTF8 # Compress if (Test-Path $script:zipPath) { Remove-Item $script:zipPath -Force } Compress-Archive -Path "$tmpDir\*" -DestinationPath $script:zipPath Write-Log "ZIP saved. Submitting to Help Wizards..." 'White' Set-Status 'Uploading results...' [System.Windows.Forms.Application]::DoEvents() } finally { Remove-Item $tmpDir -Recurse -Force -ErrorAction SilentlyContinue } # Auto-submit via SFTP $sftp = Submit-Via-SFTP -ZipPath $script:zipPath if ($sftp.success) { Write-Log 'Results submitted to Help Wizards successfully!' 'Green' Set-Status 'Submitted! We will be in touch within 1 business day.' [System.Windows.Forms.MessageBox]::Show( "Your IT assessment has been submitted to Help Wizards.`n`nWe will review your results and reach out within one business day with our findings and recommendations.`n`n$HW_PHONE`nhelpwizards.com", 'Submitted Successfully', [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information ) | Out-Null } else { Write-Log 'Auto-submit failed. Use Email Instead button.' 'Yellow' Set-Status 'Upload failed — use Email Instead as a backup.' $btnEmail.Enabled = $true } } }) # ============================================================ # EMAIL BUTTON # ============================================================ $btnEmail.Add_Click({ $subject = [uri]::EscapeDataString("IT Assessment — $($script:auditData.system.computer_name)") $body = [uri]::EscapeDataString( "Hi Help Wizards team,`n`nPlease find attached the IT Health Assessment ZIP for $($script:auditData.system.computer_name).`n`nScore: $($script:auditData.health.score)/100 ($($script:auditData.health.overall))`n`nPlease review and let me know what you find.`n`nThank you" ) $mailto = "mailto:$HW_EMAIL`?subject=$subject&body=$body" Start-Process $mailto if ($script:zipPath -and (Test-Path $script:zipPath)) { # Open folder so they can easily attach the ZIP Start-Process 'explorer.exe' "/select,`"$script:zipPath`"" } [System.Windows.Forms.MessageBox]::Show( "Your email client should have opened.`n`nAttach the ZIP file and send it to:`n$HW_EMAIL`n`nThe ZIP file location has been opened in Explorer for easy access.", 'Help Wizards — Next Step', [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information ) | Out-Null }) # ============================================================ # SFTP AUTO-SUBMIT # ============================================================ function Submit-Via-SFTP { param([string]$ZipPath) # Write embedded key to a temp file $keyFile = Join-Path $env:TEMP "hw-audit-key-$(Get-Random)" try { $SFTP_KEY | Set-Content $keyFile -Encoding ASCII # Windows needs key file permissions to be restricted — icacls icacls $keyFile /inheritance:r /grant:r "${env:USERNAME}:R" 2>$null | Out-Null # Build sftp batch commands $remoteFile = "$SFTP_REMOTE/$(Split-Path $ZipPath -Leaf)" $batchContent = "put `"$ZipPath`" $remoteFile`nexit" $batchFile = Join-Path $env:TEMP "hw-sftp-batch-$(Get-Random).txt" $batchContent | Set-Content $batchFile -Encoding ASCII # Find sftp.exe (Windows OpenSSH) $sftpExe = 'sftp' $winSftp = 'C:\Windows\System32\OpenSSH\sftp.exe' if (Test-Path $winSftp) { $sftpExe = $winSftp } $args = @( '-P', $SFTP_PORT, '-i', $keyFile, '-b', $batchFile, '-o', 'StrictHostKeyChecking=no', '-o', 'BatchMode=yes', "$SFTP_USER@$SFTP_HOST" ) $result = & $sftpExe @args 2>&1 $success = ($LASTEXITCODE -eq 0) return @{ success = $success; output = ($result -join "`n") } } finally { Remove-Item $keyFile -Force -ErrorAction SilentlyContinue Remove-Item $batchFile -Force -ErrorAction SilentlyContinue } } # ============================================================ # RUN # ============================================================ [System.Windows.Forms.Application]::Run($form)