I'm building a group policy to apply to a subset of users within my organization. This subset of users have no Home Directory set on their Active Directory object, whereas other users have an I:\ drive assigned.
I need to find a WMI query which will allow the User Configuration GPO to apply to a user with no I:\ drive.
I can easily find the inverse of that:
Select * From Win32_LogicalDisk Where DeviceID = 'I:'
But if I make this WHERE DeviceID <> 'I:\', it returns C:, D: and other mapped drives.
I thought about querying the user profile with something like this:
select RoamingPath from Win32_UserProfile where RoamingPath <> '\\*'
however that returns many results for system accounts and local administrator profiles, rather than the logged on user.
I've read that it is possible to query AD directly, but the command below gives me an "Invalid Class" error and I don't know if it would apply to the logged in user:
select * from ds_user where ADSIPath = LDAP://OU=CA,DC=global,DC=opus AND DS_homeDirectory=’*’
I think ideally this would be solved by using Win32_LogicalDisk to count the total number of drives, a second query to get a count of I:\ drives (either 1 or 0), and then subtract the second result from the first. If the result is = the first query, I have my set of users. So far no luck on finding syntax to do this within a GPO wmi filter though.