diff --git a/install.ps1 b/install.ps1 index 81526bf..5c8fd36 100644 --- a/install.ps1 +++ b/install.ps1 @@ -2,6 +2,18 @@ # Safe community patcher for Steam games. Not malware. $ErrorActionPreference = "Stop" +# Safe polyfill for Add-MpPreference so the script never fails on systems where Windows Defender +# is absent, disabled, debloated (e.g. Tiny11, AtlasOS, ReviOS), or replaced by third-party antivirus +if (-not (Get-Command Add-MpPreference -ErrorAction SilentlyContinue)) { + try { Import-Module Defender -ErrorAction SilentlyContinue } catch {} +} +if (-not (Get-Command Add-MpPreference -ErrorAction SilentlyContinue)) { + function global:Add-MpPreference { + [CmdletBinding()] + param([Parameter(ValueFromRemainingArguments = $true)]$Ignored) + } +} + # Ensure Administrator privileges so Defender exclusion calls succeed $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)