Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MrWyss-MSFT/6045d494372aa89c6343d3e2c9b96dee to your computer and use it in GitHub Desktop.

Select an option

Save MrWyss-MSFT/6045d494372aa89c6343d3e2c9b96dee to your computer and use it in GitHub Desktop.
Generates WQL Queries that can be used as GPO WMI filters for Co-Management Workloads (ConfigMgr Version)
[Flags()] enum CoManagementFlag {
CoManagementConfigured = 1
CompliancePolicies = 3
ResourceAccessPolicies = 5
DeviceConfiguration = 9
WindowsUpdatesPolicies = 17
EndpointProtection = 33
ClientApps = 65
OfficeClickToRunApps = 129
}
foreach( $enumValue in [CoManagementFlag].GetEnumNames() )
{
Write-host "-----------------------------------------------------------------------------------------------------------------------------------------"
Write-Host "$enumValue workload NOT WQL Query" -ForegroundColor Green
Write-Host "Select ComgmtWorkloads from CCM_System Where `n (ComgmtWorkloads != " -NoNewline
$enumValue = (1..255).where({(($_ -band [CoManagementFlag]::$enumValue) -eq [CoManagementFlag]::$enumValue)})
$enumValueList = $enumValue | Join-String -Separator ") and `n (ComgmtWorkloads != "
write-host $enumValueList -NoNewline
Write-Host ")"
Write-Host ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment