WQL/WMI query to check if a user exists
For some odd reason, MSFT didn’t code a straight item-level targeting rule to allow you to query local users. So, if you are renaming a local user, and it is already in existence (which it will be after you rename it), your client will log an error.
In order to avoid the error, you must check if the user exists using the following WQL:
select * from win32_useraccount where localaccount = 1 and caption like '%Administrator' select * from win32_useraccount where localaccount = 1 and caption like '%Guest'
Note that the caption property will return the computer name as the realm of the user followed by the user (like COMPUTER\Administrator); this is why it checks with a wildcard.