Overview
This post provides a PowerShell script that creates an SCCM package to check the Windows Remote Management (WinRM) status related to Windows Update. This script ensures that WinRM is configured correctly to support Windows Update operations.
Instructions
- Copy the provided PowerShell script to a location on your SCCM server.
- Adjust the script variables such as
$SCCMServer
,$SiteCode
, and$PackageSourcePath
to fit your environment. - Run the script in PowerShell to create the SCCM package to check WinRM status.
- Distribute the package to the appropriate distribution points within SCCM.
- Monitor the deployment to ensure that WinRM is correctly configured on all targeted systems.
What the Script Does
This PowerShell script automates the creation of an SCCM package that checks the Windows Remote Management (WinRM) status. The script ensures that WinRM is configured to support Windows Update, which is critical for remote management and update operations.
PowerShell Script
# Define Variables $SCCMServer = "\\YourSCCMServer" $SiteCode = "YourSiteCode" $ScriptName = "Check-Windows-Update-WinRM-Status" $ScriptDescription = "Checks the Windows Remote Management (WinRM) status related to Windows Update." $PackageSourcePath = "C:\Scripts\$ScriptName" # Load SCCM PowerShell Module Import-Module "$($Env:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" -Force # Connect to the SCCM Site cd "$SiteCode`:" # Check if a package with the same name exists and delete it $ExistingPackages = Get-CMPackage -Name $ScriptName -ErrorAction SilentlyContinue if ($ExistingPackages) { foreach ($Package in $ExistingPackages) { Remove-CMPackage -Id $Package.PackageID -Force } } # Create the Package Source Directory if it does not exist if (!(Test-Path -Path $PackageSourcePath)) { New-Item -ItemType Directory -Path $PackageSourcePath -Force } # Create the PowerShell script $ScriptContent = @' # Checks the Windows Remote Management (WinRM) status related to Windows Update winrm quickconfig -force '@ $ScriptPath = "$PackageSourcePath\Check-Windows-Update-WinRM-Status.ps1" Set-Content -Path $ScriptPath -Value $ScriptContent # Create the SCCM Package $Package = New-CMPackage ` -Name $ScriptName ` -Description $ScriptDescription ` -Path $PackageSourcePath # Create a Program for the Package $Program = New-CMProgram ` -PackageName $ScriptName ` -StandardProgramName $ScriptName ` -CommandLine "powershell.exe -ExecutionPolicy Bypass -File Check-Windows-Update-WinRM-Status.ps1" ` -ProgramRunType "WhetherOrNotUserIsLoggedOn" # Distribute the Package to the Distribution Point but do not deploy Start-CMContentDistribution ` -PackageName $ScriptName ` -DistributionPointName "YourDistributionPointName"
Explanation
This script checks the WinRM status related to Windows Update, ensuring that the remote management service is correctly configured. The package is distributed via SCCM to ensure that WinRM is properly set up across all targeted systems.
Tags:
#WinRM #WindowsUpdate #PowerShell #SCCM