← All scripts

Windows configuration

Check System Restore Status

Reports whether System Restore is enabled (not supported on server operating systems).

Download .ps1102 lines · PowerShell

Replace generic placeholder values (tenant, domain, secrets) for your own environment before running. Read it first and test safely.

<#
.SYNOPSIS
    Reports whether Windows System Restore is enabled on this device.

.DESCRIPTION
    Checks the System Restore registry (and policy) keys and prints whether System
    Restore is Enabled or Disabled. Not supported on server OSes (exits with an error).
    Writes [Info]/[Warning]/[Error] lines to STDOUT so any RMM can capture the result.

.NOTES
    Windows 10 (build 10240) or later. RMM-agnostic: capture STDOUT for a monitor/condition.
#>

[CmdletBinding()]
param ()

begin {
    # Minimum supported OS is Windows 10 (build 10240)
    if ([System.Environment]::OSVersion.Version.Build -lt 10240) {
        Write-Host -Object "`n[Warning] The minimum OS version supported by this script is Windows 10 (10240)."
        Write-Host -Object "[Warning] OS build '$([System.Environment]::OSVersion.Version.Build)' detected. This could lead to errors or unexpected results.`n"
    }

    function Test-IsServer {
        [CmdletBinding()]
        param()

        # Use CIM on PS 3+, fall back to WMI on older hosts
        $OS = if ($PSVersionTable.PSVersion.Major -lt 3) {
            Get-WmiObject -Class Win32_OperatingSystem
        } else {
            Get-CimInstance -ClassName Win32_OperatingSystem
        }

        # ProductType 2 = domain controller, 3 = server (SKU 175 handled as an exception)
        if (($OS.ProductType -eq "2" -or $OS.ProductType -eq "3") -and $OS.OperatingSystemSku -ne "175") {
            return $true
        }
    }

    # System Restore is not applicable to server operating systems
    try {
        $IsServer = Test-IsServer -ErrorAction Stop
    }
    catch {
        Write-Host "[Error] Failed to determine if this system is a server."
        Write-Host "[Error] $($_.Exception.Message)"
        exit 1
    }

    if ($IsServer) {
        Write-Host "[Error] Server operating system detected. System restore is not supported on server operating systems."
        exit 1
    }

    # Determine whether System Restore is enabled from the registry (and policy)
    function Test-SystemRestore {
        $SystemRestoreRegistryPath       = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore\"
        $PolicySystemRestoreRegistryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore\"

        if (Test-Path $SystemRestoreRegistryPath) {
            try { $SystemRestoreProperties = Get-ItemProperty -Path $SystemRestoreRegistryPath -ErrorAction Stop }
            catch { throw $_ }
        }
        else {
            return $False
        }

        if (Test-Path $PolicySystemRestoreRegistryPath) {
            try { $SystemRestorePolicyProperties = Get-ItemProperty -Path $PolicySystemRestoreRegistryPath -ErrorAction Stop }
            catch { throw $_ }
        }

        # DisableSR = 1 means System Restore is disabled by policy
        if ($SystemRestorePolicyProperties.DisableSR -eq 1) { return $False }

        # RPSessionInterval < 1 means System Restore is effectively disabled
        if ($SystemRestoreProperties.RPSessionInterval -lt 1) { return $False }

        return $True
    }
}
process {
    try {
        $SystemRestoreStatus = Test-SystemRestore -ErrorAction Stop
    }
    catch {
        Write-Host "[Error] Failed to determine if system restore is enabled on this system."
        Write-Host "[Error] $($_.Exception.Message)"
        exit 1
    }

    # Report the result to STDOUT (capture this in your RMM if desired)
    switch ($SystemRestoreStatus) {
        $True  { Write-Host "[Info] System restore is enabled on this system." }
        $False { Write-Host "[Info] System restore is disabled on this system." }
    }

    exit 0
}
end { }