Home ยป PowerShell ยป Find Ad Object By GUID in PowerShell

Find Ad Object By GUID in PowerShell

Use the Get-AdObject cmdlet in PowerShell to find ad object by GUID. It has ObjectGuid property that contains an active directory object GUID.

Refer to the following command to retrieve active directory objects by GUID.

Get-ADObject -Filter {objectGUID -eq 'f1586188-ad09-4054-a3a2-dff90e5f608a'}

In this article, we will discuss how to get ad object by guid in PowerShell using the Get-AdObject cmdlet.

Find Active Directory Object by GUID in PowerShell

Get-AdObject cmdlet in PowerShell retrieves objects from the active directory. It uses the ObjectGuid attribute to compare the provided guid and retrieve ad object.

Get-ADObject -Filter {objectGUID -eq 'f1586188-ad09-4054-a3a2-dff90e5f608a'}

In the above PowerShell script, the Get-AdObject command uses the Filter parameter to check the ObjectGuid attribute of the ad object is equal to provided guid. If it matches the condition, it gets an active directory object.

The output of the above PowerShell script to find ad object by guid is:

Find Ad Object by GUID in PowerShell
Find Ad Object by GUID in PowerShell

Cool Tip: How to convert guid to string in PowerShell!

Retrieve Ad Object by GUID in PowerShell

The Get-AdObjct cmdlet in PowerShell retrieves active directory objects based on its Identity parameter. The Identity Parameter specified the unique identity of the ad object to retrieve, it accepts GUID, SID, or SAMAccount to get ad object in PowerShell.

$userGuid = 'f1586188-ad09-4054-a3a2-dff90e5f608a'
$user = Get-ADObject -Identity $userGuid -Properties *
Write-Host $user

In the above PowerShell script, the $userGuid variable stores the identity of the object that is GUID.

The Get-AdObject uses the Identity parameter to specify GUID and retrieves ad user guid by GUID in PowerShell.

The output of the above PowerShell script to find ad user by guid in PowerShell is:

PS C:\> $userGuid = 'f1586188-ad09-4054-a3a2-dff90e5f608a'
PS C:\> $user = Get-ADObject -Identity $userGuid -Properties *
PS C:\> $user


accountExpires                  : 0
adminCount                      : 1
badPasswordTime                 : 133046969540825393
badPwdCount                     : 2
CanonicalName                   : SHELLPRO.LOCAL/Users/adam
CN                              : adam
codePage                        : 0

Conclusion

I hope the above article on how to use the Get-AdObject cmdlet in PowerShell to find ad objects by GUID is useful to you.

The ObjectGuid attribute of the Get-AdObject can be used to check for specified Guid and retrieve the ad object in PowerShell.

The Identity parameter with Get-AdObject can be used to check for specified Guid and find ad object in PowerShell.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.