2

Can someone explain how to get the ObjectGUID the same as is returned from dsquery except using powershell?

As an example.

Powershell

Get-ADGroup "MyGroup" -Properties ObjectGUID
32359aec-2e77-4b0c-b525-3e9a39083314

dsquery (application uses DSQuery don't have the command it uses)

7Jo1MncuDEu1JT6aOQgzFA==

Edit - For clarity, I want to query the AD Group in powershell and get the DSQuery result for ObjectGUID. I do not want the powershell result for ObjectGUID.

whoisearth
  • 4,080
  • 13
  • 62
  • 130

1 Answers1

5

The output from dsquery is the raw underlying binary GUID, base64-encoded.

To convert between the two formats:

# GUID to base64
$guidInstance = [guid]::new('32359aec-2e77-4b0c-b525-3e9a39083314')
[convert]::ToBase64String($guidInstance.ToByteArray())

# base64 to GUID
$binaryGUID = [convert]::FromBase64String('7Jo1MncuDEu1JT6aOQgzFA==')
[guid]::new($binaryGUID)
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206