?
Solved

Powershell piping query

Posted on 2012-03-11
7
Medium Priority
?
876 Views
Last Modified: 2012-08-13
Hi

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!
0
Comment
Question by:neil4933
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 17

Expert Comment

by:Learnctx
ID: 37708049
Someone has put together a function for exactly this. See here. Customise that to your needs.
0
 
LVL 12

Expert Comment

by:Navdeep
ID: 37708269
Hi ,

Try the following commands

get-qaduser -includeProperty ObjectGUID | where{$_.ObjectGuid -eq '1234'} | FL DisplayName, ObjectGuid

or user IncludeAllProperties instead of IncludeProperty

For a list of Guid in a csv file you can use for loop, for example guid is specified under column GUID in CSV file

Import the csv file into a var
$ColItems = import-csv D:\FileName.csv
foreach($colItem in $colItems)
        {
           $objGuid = $colItem.GUID
           get-qaduser -includeProperty ObjectGuid | where{$_.ObjectGuid -eq "$objGuid"} | FL  DisplayName, ObjectGuid

        }

Note: First test on few users.

Regards,
Navdeep [v-2nas]
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 37712396
Since the objectGUID is a unique reference you should simply be able to do:

Get-QADUser <objectGUID> | Select-Object DisplayName

Chris
0
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 

Author Comment

by:neil4933
ID: 37712619
Hi v-nas, that doesn't work.

Chris, thanks but Quest doesn't seem to work with objectGUID in that way, even though it is unique.

So, to confirm:

get-QADUser -identity User1 | fl objectGUID

objectGUID: 1234

There must be a straightforward Powershell to run that says "Get-QADUser where objectGUID is 1234"?

Thanks in advance?
0
 
LVL 17

Expert Comment

by:Learnctx
ID: 37712865
Quest converts the object guid to hex format which is why it isn't working. If you do the following it will work.

$guid = (get-qaduser username).objectguid
Get-qaduser $guid

That should work.
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 2000 total points
ID: 37713590
Quest stores it in two different values. The first is the real one, objectGUID, the second is "Guid" and is the better format.

Using that you can do this:

Get-QADUser (Get-QADuser "Chris Dent").GUID

What's in your file exactly? GUID's in this format?

12312312-1231-1231-1231-123123123123

If so, you can simply use Get-QADUser to get the lot. If not, you'd be better converting the entry to a real System.GUID object before trying to pass it in.

Chris
0
 
LVL 12

Expert Comment

by:Navdeep
ID: 37718533
Given that you use the Guid in valid system input, the code will work.

Regards,
Navdeep [v-2nas]
0

Featured Post

Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A bad practice commonly found during an account life cycle is to set its password to an initial, insecure password. The Password Reset Tool was developed to make the password reset process easier and more secure.
Wouldn't it be nice if objects in Active Directory automatically moved into the correct Organizational Units? This is what AutoAD aims to do and as a plus, it automatically creates Sites, Subnets, and Organizational Units.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question