This script retrieves a list of selected product categories from an WSUS server and searches for the corresponding category on your Software Update Point. It then will enable the subscription for this specific category.
As a precaution you have to change the scanOnly variable to actually enable this/
Before all this, the script will first create a backup of your current selected categories and export it to a timestamped CSV file.
#requirements
- SCCM console installed
- WSUS console installed
Script
Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" # Import the ConfigurationManager.psd1 module $SiteCode = Get-PSDrive -PSProvider CMSITE Set-Location "$($SiteCode.Name):\" $supCatBackupPath = "C:\SCCM_SUP_Subscribed_ProductCategories_$(Get-Date -Format 'yyyyMMdd_HHmmss').csv" $onlyScan = $true #Change this to $False if you are sure to change the Software Update Point categories. #get current selected SUP categories $subscribedCats = Get-CMSoftwareUpdateCategory -Fast | ? { $_.IsSubscribed -And $_.CategoryTypeName -eq "ProductFamily" -Or $_.CategoryTypeName -eq "Product" } #backup to CSV file $subscribedCats | Export-CSV -Path $supCatBackupPath -Delimiter ";" $wsusserver = "myWSUSserver" $wsusport = 8530 [reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | Out-Null $wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($wsusserver,$False,$wsusport) $wsusSubscription = $wsus.GetSubscription() $selectedProducts = $wsusSubscription.GetUpdateCategories() | Select Title $selectedProducts $selectedProducts.Title | % { $_ $supCat = Get-CMSoftwareUpdateCategory -Fast -Name "$_" if($supCat.IsSubscribed -eq $False) { Write-Host -ForegroundColor Red "Not subscribed" if($onlyScan -eq $False) { $supCat.IsSubscribed = $true $supCat.Put() } else { Write-Host "scan only, not changing..." } } else { Write-Host "Already subscribed" } }
0 reacties:
Post a Comment