I am trying to get the SIDs of users and groups by querying

get-wmiobject -query 'select groupcomponent,partcomponent from win32_groupuser`


__GENUS          : 2
__CLASS          : Win32_GroupUser
__DYNASTY        :
__RELPATH        : Win32_GroupUser.GroupComponent="\\\\COMPUTER\\root\\cimv2:Win32_Group.Domain=\"TESTDOMAIN\",Name=\
                   "Schema Admins\"",PartComponent="\\\\COMPUTER\\root\\cimv2:Win32_UserAccount.Domain=\"TESTDOMAIN\"
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
GroupComponent   : \\COMPUTER\root\cimv2:Win32_Group.Domain="TESTDOMAIN",Name="Schema Admins"
PartComponent    : \\COMPUTER\root\cimv2:Win32_UserAccount.Domain="TESTDOMAIN",Name="Administrator"

groupcomponent is a win32_group (https://msdn.microsoft.com/en-us/library/windows/desktop/aa394153%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396).

win32_group is contains an SID (https://msdn.microsoft.com/en-us/library/windows/desktop/aa394151%28v=vs.85%29.aspx#)

However the groupcomponent here is a string and not a win32_group as

get-wmiobject -query 'select groupcomponent.sid from win32_groupuser'

is an invalid query. How can I access groupcomponent's members as a win32_group?


The PartComponent Property contains the SID. Access it by iterating through all objects via WMI:

gwmi win32_groupuser | % { [wmi]$_.partcomponent }

or use

gwmi win32_groupuser | % { [wmi]$_.partcomponent | select SID } 

to only receive the SID.

  • How would I use this from vbscript? I'm currently using a query so I can do objWMIService.ExecQuery("select partcomponent,groupcomponent from win32_groupuser"), however that doesn't work with the commands above. – A G Apr 28 '16 at 10:06
  • @AG hmm i'm not quite sure about VB, and I never wrote a VB-Script. Always using PowerShell. You should ask this in a new question, and accept this as an answer, since your original question has been answered. – SimonS Apr 28 '16 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.