I'm not sure if this is quite possible but I'm struggling with writing the WQL query statement that would allow me to have SCCM device collections populate based on a machine variable.
Example: Device named "TestVM-01" has a machine variable named "PatchGroup" with a value of "Hour1". I would like the device collection called "Hour1" to dynamically populate any devices with the PatchGroup variable set to Hour1.
I first struggled with just querying the device variables via powershell and WMI since the SMS_MachineVarible class is a lazy property of SMS_MachineSettings so you have to call the objects by their full path.
In Powershell/WMI I can query it with something like this
(([wmi]"\\SCCM-LAB\root\sms\site_001:SMS_Machinesettings.ResourceID=11111111").machinevariables | where name -eq "PatchGroup").value
If you query SMS_MachineSettings without specifying the full path of the object, it will return the MachineVariables attribute as empty
Would anyone be able to tell me how I would write the WQL for that to pull those list of objects from the SMS_Resource class "where PatchGroup = x"?