<# Monarch Checker - PowerShell version Read-only system check. Changes nothing. Run as Administrator for full results (TPM, Defender WMI). Usage: irm monarch.charlesfr.cc | iex #> try { $Host.UI.RawUI.WindowTitle = "Monarch Checker" } catch {} function Write-C($text, $color = "Gray") { Write-Host $text -ForegroundColor $color -NoNewline } function Write-CL($text, $color = "Gray") { Write-Host $text -ForegroundColor $color } function Wait-Key { # ReadKey fails in non-interactive hosts (ISE, redirected input); fall back gracefully try { return $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown").Character } catch { return $null } } function Show-Status($st, $name, $detail) { switch ($st) { "OK" { Write-C " [ OK ] " "Green" } "WARN" { Write-C " [WARN] " "Yellow" } "FAIL" { Write-C " [FAIL] " "Red" } "INFO" { Write-C " [INFO] " "Cyan" } } Write-CL ("{0,-38} {1}" -f $name, $detail) } function Show-Section($title) { $pad = "=" * [Math]::Max(1, 70 - 5 - $title.Length - 1) Write-Host "" Write-CL (" == {0} {1}" -f $title, $pad) "White" } # ============================================================ Results $script:results = @() function Add-Check($st, $name, $detail, $fix = "") { $script:results += [PSCustomObject]@{ St=$st; Name=$name; Detail=$detail; Fix=$fix } Show-Status $st $name $detail } # ============================================================ Banner $banner = @' __ __ _ | \/ | ___ _ __ __ _ _ __ ___| |__ | |\/| |/ _ \| '_ \ / _` | '__/ __| '_ \ | | | | (_) | | | | (_| | | | (__| | | | |_| |_|\___/|_| |_|\__,_|_| \___|_| |_| Checker '@ Write-Host "" Write-CL $banner "DarkYellow" Write-Host "" Write-CL " System check tool. This tool only reads - it changes nothing." "Gray" $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isAdmin) { Write-CL " Not running as Administrator - TPM and Defender results may be incomplete." "Yellow" } Write-CL " Scanning..." "Gray" # ============================================================ Hardware Show-Section "System" # Windows $ver = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -ErrorAction SilentlyContinue if ($ver) { # The ProductName registry value still says "Windows 10" on Windows 11 (same as winver does internally), # so decide by build number: 22000+ is Windows 11. $build = [int]$ver.CurrentBuildNumber $prodName = $ver.ProductName if ($build -ge 22000) { $prodName = $prodName -replace 'Windows 10', 'Windows 11' } $dispVer = if ($ver.DisplayVersion) { $ver.DisplayVersion } else { $ver.ReleaseId } Add-Check "INFO" "Windows" ("{0} {1} (Build {2}.{3})" -f $prodName, $dispVer, $ver.CurrentBuildNumber, $ver.UBR) } # ============================================================ Security Show-Section "Security" # Antivirus try { $avProducts = Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct -ErrorAction Stop $activeAV = @() foreach ($av in $avProducts) { $state = $av.productState $enabled = (($state -shr 12) -band 0xF) -ne 0 if ($enabled) { $activeAV += $av.displayName } } if ($activeAV.Count -gt 0) { Add-Check "OK" "Antivirus" ("active ({0})" -f ($activeAV -join ", ")) } else { Add-Check "FAIL" "Antivirus" "no active antivirus detected" ` "Open Windows Security > Virus & threat protection and enable Real-time protection." } } catch { try { $def = Get-MpComputerStatus -ErrorAction Stop if ($def.AntivirusEnabled -and $def.RealTimeProtectionEnabled) { Add-Check "OK" "Antivirus" "active (Windows Defender)" } else { Add-Check "FAIL" "Antivirus" "Defender present but not fully active" ` "Open Windows Security > Virus & threat protection and enable Real-time protection." } } catch { Add-Check "WARN" "Antivirus" "could not query antivirus status" } } # dControl $dctl = Get-Process -Name "dControl" -ErrorAction SilentlyContinue if (-not $dctl) { Add-Check "OK" "Defender Control (dControl)" "not running" } else { Add-Check "FAIL" "Defender Control (dControl)" "running (may interfere with Defender)" ` "Close dControl.exe via Task Manager or its own UI." } # Memory Integrity (HVCI) $hvciRunning = $false try { $dg = Get-CimInstance -Namespace root/Microsoft/Windows/DeviceGuard -ClassName Win32_DeviceGuard -ErrorAction Stop $hvciRunning = $dg.SecurityServicesRunning -contains 2 if ($hvciRunning) { Add-Check "FAIL" "Memory Integrity (HVCI)" "enabled" ` "Windows Security > Device security > Core isolation > Memory integrity > Off, then restart." } else { $hvciCfg = (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" -Name Enabled -ErrorAction SilentlyContinue).Enabled -eq 1 if ($hvciCfg) { Add-Check "WARN" "Memory Integrity (HVCI)" "set to on, not active yet (reboot pending)" ` "Turn Memory integrity Off in Windows Security > Device security > Core isolation, then restart." } else { Add-Check "OK" "Memory Integrity (HVCI)" "disabled" } } } catch { Add-Check "WARN" "Memory Integrity (HVCI)" "could not query DeviceGuard" } # Vulnerable Driver Blocklist $blKey = "HKLM:\SYSTEM\CurrentControlSet\Control\CI\Config" $blVal = (Get-ItemProperty $blKey -Name VulnerableDriverBlocklistEnable -ErrorAction SilentlyContinue).VulnerableDriverBlocklistEnable if ($null -eq $blVal -or $blVal -eq 1) { Add-Check "FAIL" "Vulnerable Driver Blocklist" "enabled" ` "Windows Security > Device security > Core isolation > Microsoft Vulnerable Driver Blocklist > Off, then restart." } else { Add-Check "OK" "Vulnerable Driver Blocklist" "disabled" } # TPM try { $tpm = Get-CimInstance -Namespace root/cimv2/Security/MicrosoftTpm -ClassName Win32_Tpm -ErrorAction Stop if ($tpm) { $tpmEnabled = $tpm.IsEnabled_InitialValue $tpmSpec = $tpm.SpecVersion -replace ',.*', '' if ($tpmEnabled) { Add-Check "OK" "TPM" ("{0} | enabled" -f $tpmSpec) } else { Add-Check "WARN" "TPM" ("{0} | disabled" -f $tpmSpec) "Enable in BIOS or run tpm.msc > Actions > Prepare the TPM." } } else { Add-Check "WARN" "TPM" "not found or disabled" "Enable in BIOS: Intel PTT / AMD fTPM / Security Device Support." } } catch { Add-Check "WARN" "TPM" "not found or disabled (try running as Administrator)" "Enable in BIOS: Intel PTT / AMD fTPM / Security Device Support." } # Firewall $fwOff = $false foreach ($fwProfile in @("StandardProfile", "DomainProfile", "PublicProfile")) { $fwKey = "HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\$fwProfile" $fwVal = (Get-ItemProperty $fwKey -Name EnableFirewall -ErrorAction SilentlyContinue).EnableFirewall if ($fwVal -eq 0) { $fwOff = $true } } if (-not $fwOff) { Add-Check "OK" "Windows Firewall" "all profiles active" } else { Add-Check "FAIL" "Windows Firewall" "one or more profiles disabled" ` "Run as admin: netsh advfirewall set allprofiles state on." } # ============================================================ Software Show-Section "Software" # VC++ Redistributable foreach ($arch in @( @{ Label="x64"; RegKey="HKLM:\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64"; Dll="vcruntime140.dll" }, @{ Label="x86"; RegKey="HKLM:\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86"; Dll="vcruntime140.dll" } )) { $reg = Get-ItemProperty $arch.RegKey -ErrorAction SilentlyContinue $sysDir = if ($arch.Label -eq "x86") { "$env:SystemRoot\SysWOW64" } else { "$env:SystemRoot\System32" } $dllExists = Test-Path "$sysDir\$($arch.Dll)" if ($reg -and $dllExists) { Add-Check "OK" ("VC++ Redist 2015-2022 ({0})" -f $arch.Label) ("installed ({0})" -f $reg.Version) } else { $url = if ($arch.Label -eq "x64") { "https://aka.ms/vs/17/release/vc_redist.x64.exe" } else { "https://aka.ms/vs/17/release/vc_redist.x86.exe" } Add-Check "FAIL" ("VC++ Redist 2015-2022 ({0})" -f $arch.Label) "not installed" ` ("Download: {0}`n or: winget install Microsoft.VCRedist.2015+.{1}" -f $url, $arch.Label) } } # DirectX 11 $d3d11 = Test-Path "$env:SystemRoot\System32\d3d11.dll" if ($d3d11) { Add-Check "OK" "DirectX 11" "d3d11.dll present" } else { Add-Check "FAIL" "DirectX 11" "d3d11.dll missing" ` "Run Windows Update, then: sfc /scannow and DISM /Online /Cleanup-Image /RestoreHealth." } # ============================================================ Summary Write-Host "" $okCount = @($script:results | Where-Object { $_.St -eq "OK" }).Count $warnCount = @($script:results | Where-Object { $_.St -eq "WARN" }).Count $failCount = @($script:results | Where-Object { $_.St -eq "FAIL" }).Count $color = if ($failCount -gt 0) { "Red" } elseif ($warnCount -gt 0) { "Yellow" } else { "Green" } Write-CL (" Result: {0} OK, {1} warnings, {2} issues." -f $okCount, $warnCount, $failCount) $color # Fix guide $issues = @($script:results | Where-Object { $_.St -in @("FAIL","WARN") -and $_.Fix -ne "" }) if ($issues.Count -gt 0) { Write-Host "" Write-C " Press [F] to show fix instructions, or any other key to exit. " "White" $key = Wait-Key if ($key -eq 'f' -or $key -eq 'F') { Show-Section "How to Fix" foreach ($item in $issues) { $col = if ($item.St -eq "FAIL") { "Red" } else { "Yellow" } Write-Host "" Write-C " " $col Write-C ("[{0}] " -f $item.St) $col Write-CL $item.Name "White" Write-CL (" {0}" -f $item.Fix) "Gray" } Write-Host "" Write-C " Press any key to exit..." "Gray" $null = Wait-Key } } else { Write-Host "" Write-C " Everything looks good! Press any key to exit..." "Green" $null = Wait-Key } Write-Host ""