Answered by:
Help with Powershell piping query

Question
-
We are using Quest Powershell. An object has SIDvalue 1234. The name is User1.
So if I run:
get-QADUser -identity User1 | fl
One of the returned values is:
objectGUID: 1234
Now, what I need to do is find a Powershell command that will return the "DisplayName" attribute if I know the objectGUID.
Does anyone know how I can do this?
And, if I have a list of objectGUID's in a file named GUID.csv, how can I do the above?
Any help really appreciated!Sunday, March 11, 2012 8:38 PM
Answers
-
Hi,
I would like suggest you refer to the below links for more information about changing objectGUID to GUID:
http://www.powergui.org/thread.jspa?threadID=7680
And
Using objectGUID to Bind to an Object
http://msdn.microsoft.com/en-us/library/windows/desktop/ms677985(v=vs.85).aspx
Best Regards,
Yan Li
Yan Li
TechNet Community Support
Friday, March 16, 2012 7:41 AM
All replies
-
You can directly query AD using get-qadobject -identity objectguid
Get-QADObject -Identity "d9cd9083-cb47-4f63-bfc2-1a7670ef511e"
Shaba
Sunday, March 11, 2012 8:49 PM -
If you have a CSV file with GUID,
Import-Csv .\guid.csv |ForEach-Object {Get-QADObject $_.guid}
The CSV file I used is as below.
[PS] C:\Users\exadmin>Import-Csv .\guid.csv
Guid
----
82185384-3399-4357-bd0e-7fe651bfd3bc
9ba314aa-54e9-465a-8bba-4b912b119461
Good luck !
Shaba
Sunday, March 11, 2012 8:52 PM -
Hello
No, this command doesn't work:
get-qadobject -identity objectguid
It works for GUID, but not objectGUID (two different values in our case).
Sunday, March 11, 2012 9:08 PM -
PS > (Get-QADUser kazun).objectGUID 1B89525A63CA2248BF68DA5F68A9101E PS > Get-QADUser -LdapFilter "(objectGUID=\1B\89\52\5A\63\CA\22\48\BF\68\DA\5F\68\A9\10\1E)" Name Type DN ---- ---- -- Kazun user CN=Kazun.... PS > Get-QADUser -LdapFilter "(objectGUID=\1B\89\52\5A\63\CA\22\48\BF\68\DA\5F\68\A9\10\1E)" | fl displayname DisplayName : Kazun Convert objectguid from Get-QADUser to LDAP: PS > "1B89525A63CA2248BF68DA5F68A9101E" -replace "(\w{2})",'\$1' \1B\89\52\5A\63\CA\22\48\BF\68\DA\5F\68\A9\10\1E or second variant using param Identity PS > (Get-QADUser kazun).objectGUID 1B89525A63CA2248BF68DA5F68A9101E #Show nothing,because you must reverse byte order in array PS > Get-QADUser -Identity 1B89525A63CA2248BF68DA5F68A9101E PS > $guid = "1B89525A63CA2248BF68DA5F68A9101E" PS > -join (([GUID]$guid).ToByteArray() |% {"{0:x}" -f $_}) 5a52891bca634822bf68da5f68a9101e PS > Get-QADUser -Identity 5a52891bca634822bf68da5f68a9101e | fl displayname DisplayName : Kazun
Sunday, March 11, 2012 9:11 PM -
Thanks, but do you know how I would run that second variant in a script if I have a bunch of objectGUID's?
Also, would it not be easier to write a query that says:
i. get-qaduser where objectGUID is equal to first objectGUID in csv file
ii. for the value returned, give DisplayName
Sunday, March 11, 2012 9:23 PM -
#For all guids Import-Csv C:\objectguid.csv | Foreach { Get-QADUser -Identity (-join (([GUID]$_.objectguid).ToByteArray() |% {"{0:x}" -f $_})) } | Format-Table DisplayName #First only Import-Csv C:\user.csv | Select -First 1 | Foreach { Get-QADUser -Identity (-join (([GUID]$_.objectguid).ToByteArray() |% {"{0:x}" -f $_})) } | Format-Table DisplayName
Sunday, March 11, 2012 9:30 PM -
Shorter I thing:
$guid = get-QADuser 'user' |%{$_.DirectoryEntry.objectGuid} | convert-QADAttributeValue -outputTypeName 'Guid'
$u = get-qaduser -identity $guid
Sunday, March 11, 2012 11:26 PM -
Hi Kazun
So I ran the below:
Import-Csv C:\guid.csv | Foreach {Get-QADUser -Identity (-join (([GUID]$_.objectguid).ToByteArray() |% {"{0:x}" -f $_}))} | Format-Table DisplayNameBut I am not getting any results back? Even though the objectGUID listed in the CSV file definately matches that of an AD user?
Tuesday, March 13, 2012 1:03 AM -
Hi,
I would like suggest you refer to the below links for more information about changing objectGUID to GUID:
http://www.powergui.org/thread.jspa?threadID=7680
And
Using objectGUID to Bind to an Object
http://msdn.microsoft.com/en-us/library/windows/desktop/ms677985(v=vs.85).aspx
Best Regards,
Yan Li
Yan Li
TechNet Community Support
Friday, March 16, 2012 7:41 AM