Query WMI for User Rights using PowerShell

This PowerShell script can be used to query WMI in order to confirm User Rights (which are usually set via GPO).  I have used this in ConfigMgr Compliance Configuration Items.

# Query WMI for User Rights
# Modify this Variable to select the User Right to Query
$PropertyValue = 'SeTimeZonePrivilege'
# Standard Variables
$Class = 'RSOP_UserPrivilegeRight'
$NameSpace = 'root\rsop\computer'
$Property = 'UserRight'
$Setting = 'AccountList'
# Execute Query, sort output alphabetically
$Value = (Get-WMIObject $Class -namespace $NameSpace | Where {$_.$Property -eq "$PropertyValue" -and $_.precedence -eq 1} | Select -expand $Setting | Sort) -join ", "
If (!$Value) {"NULL"}
Else {$Value}

Leave a Comment

Your email address will not be published.