VMware User Environment Manager Condition Logic

One of my customers is using UEM and wants to set up a default printer per user group, but only set that default printer if the user hasn't already got one configured.  Setting up a default printer as a User Environment policy is trivial, but the conditions to preserve existing settings were interesting.

We determined that, if the current default printer contains either the words "Microsoft" or "Webex", then we'd consider it to be unset and would correct it, otherwise we'd leave it alone.  Of course, we also need to detect that the computer is in the correct room group, too, so what's that logic look like?  I wrote it out in PowerShell style pseudo-code like this: If ((DefaultPrinter -match "Microsoft" -or DefaultPrinter -match "WebEx") -and ComputerGroup -eq "RoomA"){Set Default Printer}.

My first challenge came from the fact that, while UEM Conditions do offer logical AND and OR, they do not offer parenthesis.  When I'm combining ANDs and ORs, I need parenthesis to make the logic easily readable (and thus, intuitive), so I decided to model out the logic in PowerShell.  I first created 3 boolean variables with meaningful names:

$WebEx = $True
$Microsoft = $False
$Room = $True

I then tried various combinations and orders of the statements, like $Room -and $WebEx -or $Microsoft vs. $WebEx -or $Microsoft -and $Room and tweaked which of those conditions was true or false to try out the various combinations.  Eventually, I came up with the order that I listed them above as being the correct order: $WebEx -or $Microsoft -and $Room, which makes sense, since it just goes left to right without the parenthesis to chunk it up.

After I figured that out, I realized that a Condition Set would really improve the readability of the configurations (and make it easier to scale it out), so I went that route instead.  I created a Condition Set called No Default Printer and set it to check if the default printer was either of the above, then set my Printer configuration to check for the No Default Printer set AND the room group membership.

So, what am I actually looking at when I talk about checking the default printer?  The registry, of course.  In UEM, I created Registry Value conditions that read the actual data that is stored in that registry value (as opposed to Registry Key conditions, which simply check for the existence of a key).  I'm checking the HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device value to see if it Contains "WebEx", and then another Condition to see if that same value Contains "Microsoft".  I then pressed the drop-down arrow next to Edit while selecting the second condition and changed it to OR.  With that Condition Set configured, I then applied it to my Printer Mappings User Environment policy, and we were good to go.


Popular posts from this blog

Deleting Orphaned (AKA Zombie) VMDK Files

Clone a Standard vSwitch from one ESXi Host to Another

vCenter Server Appliance Crash due to Full /Storage/SEAT Partition