Get All Intune Windows Updates Settings in Powershell

# PowerShell Script to Display Intune Windows Update Settings
# This script retrieves and displays Windows Update settings managed by Intune

# Define the registry paths for Intune Windows Update settings
$registryPaths = @(
    "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Update",
    "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\Update"
)

# Function to get registry values
function Get-IntuneUpdateSettings {
    param (
        [Parameter(Mandatory = $true)]
        [string]$Path
    )

    try {
        if (Test-Path -Path $Path) {
            $values = Get-ItemProperty -Path $Path -ErrorAction SilentlyContinue
            if ($values) {
                $values.PSObject.Properties | Where-Object { 
                    $_.Name -notlike "PS*" -and 
                    $_.Name -notlike "*WinningProvider*" -and
                    $_.Name -notlike "*ProviderSet*"
                } | ForEach-Object {
                    [PSCustomObject]@{
                        Path  = $Path
                        Name  = $_.Name
                        Value = $_.Value
                        Type  = if ($null -eq $_.Value) { "Null" } else { $_.Value.GetType().Name }
                    }
                }
            }
        }
    }
    catch {
        Write-Warning "Error accessing $Path : $_"
    }
}

# Function to get setting description
function Get-SettingDescription {
    param (
        [string]$SettingName,
        [object]$Value
    )

    switch -Regex ($SettingName) {
        "BranchReadinessLevel" {
            switch ($Value) {
                0 { return "Windows Insider - Fast" }
                8 { return "Windows Insider - Slow" }
                16 { return "Semi-Annual Channel (Targeted)" }
                32 { return "Semi-Annual Channel" }
                default { return "Unknown Branch Level" }
            }
        }
        "DeferQualityUpdatesPeriodInDays" {
            return "Number of days to defer quality updates"
        }
        "DeferFeatureUpdatesPeriodInDays" {
            return "Number of days to defer feature updates"
        }
        "ConfigureFeatureUpdateUninstallPeriod" {
            return "Number of days before a feature update can be uninstalled"
        }
        "ActiveHoursStart" {
            return "Start of active hours (in 24-hour format)"
        }
        "ActiveHoursEnd" {
            return "End of active hours (in 24-hour format)"
        }
        "ScheduleRestartWarning" {
            return "Hours before restart when warning is shown"
        }
        "ScheduleImminentRestartWarning" {
            return "Minutes before restart when imminent warning is shown"
        }
        "ConfigureDeadlineForFeatureUpdates" {
            return "Days before forced restart after feature update"
        }
        "AutoRestartRequiredNotificationDismissal" {
            switch ($Value) {
                1 { return "Allow user to dismiss restart notification" }
                2 { return "Force restart after specified time" }
                default { return "Unknown notification dismissal setting" }
            }
        }
        "AllowAutoUpdate" {
            switch ($Value) {
                0 { return "Auto Update Disabled" }
                1 { return "Auto Update Enabled" }
                default { return "Unknown auto update setting" }
            }
        }
        "PauseQualityUpdates" {
            switch ($Value) {
                0 { return "Quality Updates Not Paused" }
                1 { return "Quality Updates Paused" }
                default { return "Unknown pause setting" }
            }
        }
        "PauseFeatureUpdates" {
            switch ($Value) {
                0 { return "Feature Updates Not Paused" }
                1 { return "Feature Updates Paused" }
                default { return "Unknown pause setting" }
            }
        }
        "SetDisableUXWUAccess" {
            switch ($Value) {
                0 { return "Windows Update UI Access Enabled" }
                1 { return "Windows Update UI Access Disabled" }
                default { return "Unknown UI access setting" }
            }
        }
        "ManagePreviewBuilds" {
            switch ($Value) {
                0 { return "Preview Builds Disabled" }
                1 { return "Preview Builds Enabled" }
                default { return "Unknown preview builds setting" }
            }
        }
        default {
            return "No description available"
        }
    }
}

# Clear the screen
Clear-Host

# Set console colors
$host.UI.RawUI.ForegroundColor = "White"
$host.UI.RawUI.BackgroundColor = "Black"

# Collection for all results
$allResults = @()

# Get settings from registry paths
Write-Host "Retrieving Intune Windows Update settings..." -ForegroundColor Cyan
foreach ($path in $registryPaths) {
    if (Test-Path -Path $path) {
        $results = Get-IntuneUpdateSettings -Path $path
        $allResults += $results
        $parentKey = $path -replace '^HKLM:\\', ''
        Write-Host "? Found $(($results | Measure-Object).Count) settings in $parentKey" -ForegroundColor Green
    }
    else {
        $parentKey = $path -replace '^HKLM:\\', ''
        Write-Host "? Path not found: $parentKey" -ForegroundColor Red
    }
}

# Display summary
$totalSettings = ($allResults | Measure-Object).Count
Write-Host "`nFound $totalSettings Windows Update settings`n" -ForegroundColor Yellow

# Group settings by category
$updateSettings = $allResults | Where-Object { 
    $_.Name -match "Defer|Pause|Update|Quality|Feature|Branch|Ring"
}

$scheduleSettings = $allResults | Where-Object { 
    $_.Name -match "Schedule|ActiveHours|Day|Time|Period|Start|End"
}

$restartSettings = $allResults | Where-Object { 
    $_.Name -match "Restart|Reboot|Deadline|Grace"
}

# Function to display settings
function Show-Settings {
    param (
        [string]$Title,
        [array]$Settings
    )
    
    Write-Host "`n============== $Title ==============" -ForegroundColor Yellow
    
    if ($Settings.Count -eq 0) {
        Write-Host "No settings found in this section." -ForegroundColor Gray
    }
    else {
        foreach ($setting in $Settings) {
            $relativePath = $setting.Path -replace '^HKEY_LOCAL_MACHINE\\|^HKLM:\\', ''
            $keyPath = Split-Path -Path $relativePath -Leaf
            
            Write-Host "$keyPath\" -NoNewline -ForegroundColor Cyan
            Write-Host "$($setting.Name): " -NoNewline -ForegroundColor Green
            
            if ($setting.Type -eq 'Int32') {
                Write-Host "$($setting.Value) (Decimal)" -NoNewline -ForegroundColor White
                $description = Get-SettingDescription -SettingName $setting.Name -Value $setting.Value
                Write-Host " - $description" -ForegroundColor Gray
            }
            elseif ($null -eq $setting.Value) {
                Write-Host "(null)" -ForegroundColor Gray
            }
            else {
                Write-Host "$($setting.Value)" -ForegroundColor White
            }
        }
    }
}

# Display settings by category
Show-Settings -Title "UPDATE POLICY SETTINGS" -Settings $updateSettings
Show-Settings -Title "SCHEDULE SETTINGS" -Settings $scheduleSettings
Show-Settings -Title "RESTART SETTINGS" -Settings $restartSettings

# Display other important settings
$otherSettings = $allResults | Where-Object { 
    $_.Name -match "Allow|Set|Manage|Configure" -and 
    -not ($updateSettings.Name -contains $_.Name) -and
    -not ($scheduleSettings.Name -contains $_.Name) -and
    -not ($restartSettings.Name -contains $_.Name)
}

Show-Settings -Title "OTHER IMPORTANT SETTINGS" -Settings $otherSettings

Write-Host "`nScript completed successfully." -ForegroundColor Green 
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...