Jump to content
Sign in to follow this  

Retrieve AD SID on remote computer

Recommended Posts

Anyone have any clues on how to retrieve the SID of a current logged in user on a remote computer? I was looking at ScriptOMatic for WMI code, but couldn't find anything that would retrieve Active Directory SIDs. Only would retrieve the SID of local users on the machine.

Share this post

Link to post
Share on other sites

look for scriptomatic in scripts and scraps (requires beta)

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_SID", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "AccountName: " & $objItem.AccountName & @CRLF
      $strBinaryRepresentation = $objItem.BinaryRepresentation(0)
      $Output = $Output & "BinaryRepresentation: " & $strBinaryRepresentation & @CRLF
      $Output = $Output & "ReferencedDomainName: " & $objItem.ReferencedDomainName & @CRLF
      $Output = $Output & "SID: " & $objItem.SID & @CRLF
      $Output = $Output & "SidLength: " & $objItem.SidLength & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_SID" )

SciTE for AutoItDirections for Submitting Standard UDFs


Don't argue with an idiot; people watching may not be able to tell the difference.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...