configure, and manage a WSUS server, including: Installing the WSUS role Setting content storage Running post-install tasks Configuring sync settings Setting update categories/classifications Enabling automatic synchronization Running cleanup tasks 🚀 WSUS PowerShell Automation Script powershell Copy Edit # ================================ # WSUS Automated Setup Script # ================================ # VARIABLES $wsusContentPath = "D:\WSUS" $wsusSQLInstance = "WID" # or use "SERVERNAME\INSTANCE" for full SQL $wsusPort = 8530 $productsToSync = @( "Windows 10", "Windows Server 2019" ) $classificationsToSync = @( "Security Updates", "Critical Updates" ) # ------------------------------- # 1. Install WSUS Role & Features # ------------------------------- Install-WindowsFeature -Name UpdateServices, UpdateServices-WidDB, UpdateServices-Services -IncludeManagementTools # ------------------------------- # 2. Run Post-Install Configuration # ------------------------------- & "C:\Program Files\Update Services\Tools\wsusutil.exe" postinstall CONTENT_DIR=$wsusContentPath # ------------------------------- # 3. Import WSUS Module # ------------------------------- Import-Module -Name UpdateServices # ------------------------------- # 4. Connect to WSUS Server # ------------------------------- $wsus = Get-WsusServer -Name $env:COMPUTERNAME -PortNumber $wsusPort # ------------------------------- # 5. Configure Products to Sync # ------------------------------- $wsus.GetSubscription().GetUpdateCategories() | ForEach-Object { if ($productsToSync -contains $_.Title) { $_.Children | ForEach-Object { $_.Enabled = $true } $_.Enabled = $true } } # ------------------------------- # 6. Configure Classifications to Sync # ------------------------------- $wsus.GetSubscription().GetUpdateClassifications() | ForEach-Object { if ($classificationsToSync -contains $_.Title) { $_.Enabled = $true } } # ------------------------------- # 7. Configure Sync Schedule # ------------------------------- $subscription = $wsus.GetSubscription() $subscription.SynchronizeAutomatically = $true $subscription.SynchronizeAutomaticallyTimeOfDay = [datetime]::Now.TimeOfDay $subscription.Save() # ------------------------------- # 8. Start Initial Sync # ------------------------------- $wsus.GetSubscription().StartSynchronization() # ------------------------------- # 9. Run WSUS Cleanup Tasks # ------------------------------- $cleanupManager = $wsus.GetCleanupManager() $cleanupManager.PerformCleanup( $true, # ObsoleteUpdates $true, # UnneededContentFiles $true, # ExpiredUpdates $true, # SupersededUpdates $true # Computers not contacting server ) Write-Host "WSUS Setup & Initial Configuration Complete!" -ForegroundColor Green