<# VeriCat scanner v0 (Windows). READ-ONLY: reads hardware facts, writes a JSON + text report. Run in PowerShell: powershell -ExecutionPolicy Bypass -File .\vericat_scan.ps1 -Upload Run PowerShell "as Administrator" to also get drive health and the security-chip version. It never changes anything on the computer. Written for Windows PowerShell 5.1 (built into Windows 10/11). #> param( [switch]$Upload, [string]$OutDir = ".", [string]$Server = "https://vericat.app" ) $ErrorActionPreference = "SilentlyContinue" $Version = "0.1.2-windows" # PS 5.1 quirk: stops ConvertTo-Json from turning lists into {value, Count} Remove-TypeData System.Array function Num($v) { if ($null -eq $v -or "$v" -eq "") { return $null }; try { return [int64]$v } catch { return $null } } function Txt($v) { if ($null -eq $v) { return $null }; $s = "$v".Trim(); if ($s -eq "") { return $null }; return $s } $IsAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator) # ---------- system ---------- $cs = Get-CimInstance Win32_ComputerSystem $bios = Get-CimInstance Win32_BIOS $bb = Get-CimInstance Win32_BaseBoard $os = Get-CimInstance Win32_OperatingSystem $biosDate = $null if ($bios.ReleaseDate) { $biosDate = ([datetime]$bios.ReleaseDate).ToString("MM/dd/yyyy") } $system = [ordered]@{ sys_vendor = Txt $cs.Manufacturer product_name = Txt $cs.Model product_version = Txt $cs.SystemFamily board_vendor = Txt $bb.Manufacturer board_name = Txt $bb.Product bios_vendor = Txt $bios.Manufacturer bios_version = Txt $bios.SMBIOSBIOSVersion bios_date = $biosDate serial = Txt $bios.SerialNumber # readable without admin on Windows board_serial = Txt $bb.SerialNumber } # ---------- battery (powercfg report: works without admin) ---------- $batteries = @() $xmlPath = Join-Path $env:TEMP ("vericat-battery-{0}.xml" -f $PID) powercfg /batteryreport /xml /output "$xmlPath" | Out-Null if (Test-Path $xmlPath) { try { [xml]$bx = Get-Content -Raw $xmlPath $i = 0 foreach ($b in @($bx.BatteryReport.Batteries.Battery)) { if ($null -eq $b) { continue } $design = Num $b.DesignCapacity # mWh $full = Num $b.FullChargeCapacity # mWh $health = $null if ($design -and $full) { $health = [math]::Round(100.0 * $full / $design, 1) } $batteries += [ordered]@{ name = "BAT$i" manufacturer = Txt $b.Manufacturer model = Txt $b.Id technology = Txt $b.Chemistry serial = Txt $b.SerialNumber cycle_count = Num $b.CycleCount full = if ($full) { [math]::Round($full / 1000.0, 1) } else { $null } design = if ($design) { [math]::Round($design / 1000.0, 1) } else { $null } unit = "Wh" health_pct = $health status = $null charge_pct = $null } $i++ } } catch {} Remove-Item $xmlPath -Force } $wb = Get-CimInstance Win32_Battery | Select-Object -First 1 if ($wb -and $batteries.Count -gt 0) { $batteries[0].charge_pct = Num $wb.EstimatedChargeRemaining $batteries[0].status = switch ([int]$wb.BatteryStatus) { 1 { "Discharging" } 2 { "On AC" } 3 { "Full" } default { $null } } } # ---------- cpu / gpu ---------- $p = Get-CimInstance Win32_Processor | Select-Object -First 1 $cpu = [ordered]@{ model = Txt $p.Name; threads = Num $p.NumberOfLogicalProcessors } $gpu = @(Get-CimInstance Win32_VideoController | ForEach-Object { Txt $_.Name } | Where-Object { $_ -and $_ -notmatch "Remote|Basic Display|Virtual Display|Mirage|DisplayLink" } | Select-Object -Unique) # ---------- memory ---------- $memTypes = @{ 20 = "DDR"; 21 = "DDR2"; 24 = "DDR3"; 26 = "DDR4"; 27 = "LPDDR"; 28 = "LPDDR2"; 29 = "LPDDR3"; 30 = "LPDDR4"; 34 = "DDR5"; 35 = "LPDDR5" } $formFactors = @{ 7 = "Row Of Chips"; 8 = "DIMM"; 12 = "SODIMM" } $modules = @() foreach ($m in @(Get-CimInstance Win32_PhysicalMemory)) { if ($null -eq $m) { continue } $speed = $m.ConfiguredClockSpeed; if (-not $speed) { $speed = $m.Speed } $type = $memTypes[[int]$m.SMBIOSMemoryType] $ff = $formFactors[[int]$m.FormFactor] $modules += [ordered]@{ size = "{0} GB" -f [math]::Round($m.Capacity / 1GB) form_factor = $ff locator = Txt $m.DeviceLocator type = $type speed = if ($speed) { "$speed MT/s" } else { $null } manufacturer = Txt $m.Manufacturer serial_number = Txt $m.SerialNumber part_number = Txt $m.PartNumber } } $slots = (Get-CimInstance Win32_PhysicalMemoryArray | Measure-Object -Property MemoryDevices -Sum).Sum $memory = [ordered]@{ total_gb = [math]::Round($cs.TotalPhysicalMemory / 1GB, 1) modules = if ($modules.Count) { $modules } else { $null } empty_slots = if ($slots) { [math]::Max(0, [int]$slots - $modules.Count) } else { $null } } # ---------- drives ---------- # Get-PhysicalDisk enums come back as numbers on some PCs and names on others: accept both. $disks = @() $diskNote = $null $pd = @(Get-PhysicalDisk | Where-Object { $_ }) if (-not $pd.Count) { $pd = @(Get-CimInstance -Namespace root/Microsoft/Windows/Storage -ClassName MSFT_PhysicalDisk | Where-Object { $_ }) } foreach ($d in $pd) { try { $bus = "$($d.BusType)" if ($bus -eq "7" -or $bus -eq "USB") { continue } $hs = "$($d.HealthStatus)" $health = $null if ($IsAdmin) { $rc = $d | Get-StorageReliabilityCounter if ($rc) { $errs = 0 foreach ($v in @($rc.ReadErrorsUncorrected, $rc.WriteErrorsUncorrected)) { if ($v) { $errs += [int64]$v } } $health = [ordered]@{ percent_used = Num $rc.Wear tb_written = $null # Windows doesn't expose host writes here power_on_hours = Num $rc.PowerOnHours unsafe_shutdowns = $null media_errors = $errs } } } $disks += [ordered]@{ device = "disk$($d.DeviceId)" model = Txt $d.FriendlyName size_gb = [math]::Round([double]$d.Size / 1e9, 1) serial = Txt $d.SerialNumber firmware = Txt $d.FirmwareVersion smart_passed = ($hs -eq "0" -or $hs -eq "Healthy") health = $health } } catch { $diskNote = "drive read error: $($_.Exception.Message)" } } if (-not $disks.Count) { # Last resort: basic drive identity (no health counters) from the older WMI class. foreach ($w in @(Get-CimInstance Win32_DiskDrive | Where-Object { $_ -and "$($_.InterfaceType)" -ne "USB" })) { $disks += [ordered]@{ device = "disk$($w.Index)"; model = Txt $w.Model; size_gb = [math]::Round([double]$w.Size / 1e9, 1) serial = Txt $w.SerialNumber; firmware = Txt $w.FirmwareRevision; smart_passed = $null; health = $null } } if (-not $diskNote) { $diskNote = "Get-PhysicalDisk found $($pd.Count) drive(s); $(if ($Error.Count) { $Error[0].ToString() } else { 'no error' })" } } # ---------- integrity checks ---------- $virt = "none" $ident = "$($cs.Manufacturer) $($cs.Model) $($bios.Manufacturer) $($bios.SerialNumber)" if ($ident -match "VMware") { $virt = "vmware" } elseif ($ident -match "VirtualBox|innotek") { $virt = "oracle" } elseif ($ident -match "QEMU|KVM|Bochs") { $virt = "kvm" } elseif ($ident -match "Xen") { $virt = "xen" } elseif ($ident -match "Parallels") { $virt = "parallels" } elseif ($cs.Model -match "Virtual Machine" -and $cs.Manufacturer -match "Microsoft") { $virt = "microsoft" } # Note: Win32_ComputerSystem.HypervisorPresent is TRUE on many real PCs (Windows security # features run a hypervisor), so it is NOT used as a VM signal. $tpmVersion = $null; $tpmPresent = $false if ($IsAdmin) { $t = Get-CimInstance -Namespace root/cimv2/Security/MicrosoftTpm -ClassName Win32_Tpm if ($t) { $tpmPresent = $true; $tpmVersion = ("$($t.SpecVersion)" -split ",")[0].Trim().Split(".")[0] } } if (-not $tpmPresent) { $pnp = Get-CimInstance Win32_PnPEntity | Where-Object { $_.Name -like "*Trusted Platform Module*" } | Select-Object -First 1 if ($pnp) { $tpmPresent = $true; if ($pnp.Name -match "(\d)\.\d") { $tpmVersion = $Matches[1] } } } $checks = [ordered]@{ virtualization = $virt hypervisor_flag = ($virt -ne "none") tpm_present = $tpmPresent tpm_version = $tpmVersion ran_as_admin = $IsAdmin } $report = [ordered]@{ vericat_version = $Version scanned_at = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss+00:00") os = Txt "$($os.Caption) $($os.Version)" system = $system battery = @($batteries) cpu = $cpu gpu = @($gpu) memory = $memory disks = @($disks) checks = $checks } # ---------- output ---------- $lines = @() $lines += "VeriCat report $($report.scanned_at)" $lines += "$($system.sys_vendor) $($system.product_name) (BIOS $($system.bios_version))" $lines += "Serial: $($system.serial)" if ($batteries.Count) { foreach ($b in $batteries) { $lines += "Battery: $($b.cycle_count) charge cycles (original capacity $($b.design) Wh)" } } else { $lines += "Battery: none found" } $lines += "CPU: $($cpu.model)" foreach ($g in $gpu) { $lines += "GPU: $g" } $lines += "RAM: $($memory.total_gb) GB usable" foreach ($m in $modules) { $lines += " - $($m.locator): $($m.size) $($m.type) $($m.speed) $($m.manufacturer) $($m.part_number)" } foreach ($d in $disks) { $extra = "" if ($d.health -and $null -ne $d.health.power_on_hours) { $extra = ", $($d.health.power_on_hours) hours powered on" } $lines += "Drive $($d.device): $($d.model) $($d.size_gb) GB$extra" } if ($diskNote) { $lines += "Drive note: $diskNote" } $lines += "Checks: VM=$virt, TPM $(if ($tpmVersion) { $tpmVersion } else { 'none' }), admin=$IsAdmin" $text = $lines -join "`r`n" $json = ConvertTo-Json -InputObject $report -Depth 8 $stamp = (Get-Date).ToString("MMddyyyy HHmm") $base = Join-Path $OutDir "$stamp vericat-report" [IO.File]::WriteAllText("$base.json", $json, (New-Object Text.UTF8Encoding $false)) [IO.File]::WriteAllText("$base.txt", $text, (New-Object Text.UTF8Encoding $false)) Write-Output $text Write-Output "" Write-Output "Saved: $base.json / .txt" if ($Upload) { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $ErrorActionPreference = "Stop" try { $resp = Invoke-RestMethod -Method Post -Uri "$Server/api/reports" -ContentType "application/json" -UserAgent "VeriCat-Scanner/$Version" ` -Body ([Text.Encoding]::UTF8.GetBytes($json)) Write-Output "Your report link: $($resp.url)" if ($resp.remove_url) { Write-Output "Private removal link (save it, shown once): $($resp.remove_url)" } } catch { Write-Output "Upload failed: $($_.Exception.Message)" } }