This is a script to append the Windows 11 operating system requirement in Configuration Manager application deployments.
I recently needed to test some applications on Windows 11 as part of a Windows 10 to Windows 11 migration. But all of the applications in configuration manager had an operating system requirement set, which didn’t include Windows 11! So none of the applications deployed.
Windows 11 Operating System Requirement in Configuration Manager
Organisations should not be setting operating system rules at the application-level. They should use a global condition by defining a condition under:
Software Library -> Application Management -> Global Conditions
And then in the application deployment type, add a Requirement, select Custom and select the global condition as the requirement:
That way, we don’t need to faff around writing scripts to retrospectively fix the conditions (On that note, my next job is simply to replace them all with the global condition above! But that’s one for another day.).
Append to SCCM Application Deployment Type Requirement
As ever, no warranty is implied with my script excerpts. So I’d advise testing on a single application in the first instance. In this instance, I check that the operating system requirement already has “Windows 10” configured, and if it does, it’s safe to assume that it should also be allowed to install on Windows 11 (should the device in question be upgraded).
# Site configuration
$SiteCode = "YOUR-SITE-CODE" # Site code
$ProviderMachineName = "YOUR-SCCM-SERVER" # SMS Provider machine name
# Customizations
$initParams = @{}
#$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging
#$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors
# Do not change anything below this line
# Import the ConfigurationManager.psd1 module
if((Get-Module ConfigurationManager) -eq $null) {
Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams
}
# Connect to the site's drive if it is not already present
if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) {
New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams
}
# Set the current location to be the site code.
Set-Location "$($SiteCode):\" @initParams
cls
#W11 requirement
$operand = "Windows/All_x64_Windows_11_and_higher_Clients"
$namedRequirement = "All Windows 11 (64-bit)"
$cmApps = Get-CMApplication
#Use to test a finite amount of apps
#-Name "xxxx"
#| select -First 1
foreach($cmApp in $cmApps) {
write-host "Processing $($cmApp.LocalizedDisplayName)"
$addedRule = $false
$xml = [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::DeserializeFromString($cmApp.SDMPackageXML,$True)
$numDTS = $xml.DeploymentTypes.count
$dts = $xml.DeploymentTypes
foreach ($dt in $dts)
{
#loop through requirements
foreach($requirement in $dt.Requirements)
{
#existing rule name
#Example value: Operating system One of {All Windows 7 (64-bit), All Windows 7 (32-bit), All Windows Server 2008 R2 (64-bit), All Windows 8.1 (64-bit), All Windows 10 (64-bit)}
$rName = $requirement.Name
#if requirement is an operating system one
if($requirement.Expression.gettype().name -eq 'OperatingSystemExpression')
{
$foundWin10 = $requirement.Expression.Operands | Where-Object { $_.RuleId -eq "Windows/All_x64_Windows_10_and_higher_Clients" }
$foundWin11 = $requirement.Expression.Operands | Where-Object { $_.RuleId -eq $operand }
If ($foundWin10)
{
#if we find Windows 10, we assume we also need to add Windows 11
if (!($foundWin11)) {
write-host "Appending value to it $rName."
$requirement.Expression.Operands.Add("$operand")
$requirement.Name = [regex]::replace($requirement.Name, '(?<=Operating system One of {)(.*)(?=})', "`$1, $namedRequirement")
$addedRule = $true
#assume one operating system rule
break
} else {
write-host "W11 already exists."
}
}
}
}
}
if ($addedRule) {
$UpdatedXML = [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::SerializeToString($XML, $True)
$cmApp.SDMPackageXML = $UpdatedXML
$cmApp.put()
Set-CMApplication -InputObject $cmApp
write-host "Saved."
} else {
write-host "No changes."
}
}
You can, of course, modify this script to add whichever operating system requirements you need. And at the time of writing, here is a list of supported operating systems:
Windows/All_x86_Windows_XP
Windows/All_x64_Windows_XP_Professional
Windows/x64_Windows_XP_Professional_SP2
Windows/x86_Windows_XP_Professional_Service_Pack_3
Windows/All_x64_Windows_Vista
Windows/All_x86_Windows_Vista
Windows/x64_Windows_Vista_SP2
Windows/x86_Windows_Vista_SP2
Windows/All_x64_Windows_7_Client
Windows/All_x86_Windows_7_Client
Windows/x64_Windows_7_Client
Windows/x64_Windows_7_SP1
Windows/x86_Windows_7_Client
Windows/x86_Windows_7_SP1
Windows/All_ARM_Windows_8_Client
Windows/All_x64_Windows_8_Client
Windows/All_x86_Windows_8_Client
Windows/All_ARM_Windows_8.1_Client
Windows/All_x64_Windows_8.1_Client
Windows/All_x86_Windows_8.1_Client
Windows/All_x64_Windows_10_and_higher_Clients
Windows/All_x86_Windows_10_and_higher_Clients
Windows/All_x64_Windows_Server_2003_Non_R2
Windows/All_x64_Windows_Server_2003_R2
Windows/All_x86_Windows_Server_2003_Non_R2
Windows/All_x86_Windows_Server_2003_R2
Windows/x64_Windows_Server_2003_R2_SP2
Windows/x64_Windows_Server_2003_SP2
Windows/x86_Windows_Server_2003_R2_SP2
Windows/x86_Windows_Server_2003_SP2
Windows/All_x64_Windows_Server_2008
Windows/All_x64_Windows_Server_2008_R2
Windows/All_x86_Windows_Server_2008
Windows/x64_Windows_Server_2008_R2
Windows/x64_Windows_Server_2008_R2_CORE
Windows/x64_Windows_Server_2008_R2_SP1
Windows/x64_Windows_Server_2008_R2_SP1_Core
Windows/x64_Windows_Server_2008_SP2
Windows/x64_Windows_Server_2008_SP2_Core
Windows/x86_Windows_Server_2008_SP2
Windows/All_x64_Windows_Server_8
Windows/All_x64_Windows_Server_2012_R2
Windows/All_Embedded_Windows_XP
Windows/All_x64_Windows_Embedded_8.1_Industry
Windows/All_x64_Windows_Embedded_8_Industry
Windows/All_x64_Windows_Embedded_8_Standard
Windows/All_x86_Windows_Embedded_8.1_Industry
Windows/All_x86_Windows_Embedded_8_Industry
Windows/All_x86_Windows_Embedded_8_Standard
Windows/x64_Embedded_Windows_7
Windows/x86_Embedded_Windows_7
Windows/All_Windows_Client_Server

