Solved

Power Shell Get-ADUser

Posted on 2014-04-29
8
1,454 Views
Last Modified: 2014-04-30
HI


I am trying to see if anyone is using extensionattribute12 but the PS command line I have below does not give me any information back

can some one suggest something that will work?

Get-ADUser -Properties extensionattribute12 | select extensionAttribute12  | Export-CSV -path c:\CustomAttr12.csv
0
Comment
Question by:SEHC
[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
  • 4
  • 2
  • 2
8 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 40030328
$name = $samaccount

Get-ADUser -LDAPFilter "(sAMAccountName=$Name)" -Properties extensionAttribute12 |
Select-Object -ExpandProperty extensionAttribute12 | Export-CSV -path c:\CustomAttr12.csv 

Open in new window

0
 
LVL 4

Author Comment

by:SEHC
ID: 40030339
I get the following error

Get-ADUser : The search filter cannot be recognized
At C:\GetAD.ps1:3 char:11
+ Get-ADUser <<<<  -LDAPFilter "(sAMAccountName=$Name)" -Properties extensionAt
tribute12 |
    + CategoryInfo          : NotSpecified: (:) [Get-ADUser], ADException
    + FullyQualifiedErrorId : The search filter cannot be recognized,Microsoft
   .ActiveDirectory.Management.Commands.GetADUser
0
 
LVL 29

Expert Comment

by:becraig
ID: 40030396
Try running just this:
$name = $samaccount
Get-ADUser -LDAPFilter "(sAMAccountName=$Name)" 

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:SEHC
ID: 40030405
that does not get me the information that I am looking for???? do you just want me to test that command?
0
 
LVL 29

Assisted Solution

by:becraig
becraig earned 250 total points
ID: 40030468
Yes I want to be sure the filter actually works, if the command is successful then the filter works and it might be something else in the  command

Both of the below work for me:
(of course in one forest and not another as I do not have that property in one)

Get-ADUser -LDAPFilter "(sAMAccountName=$Name)" -Properties extensionAttribute12 | Select-Object -ExpandProperty extensionAttribute12 | Export-CSV -path c:\ext12attr.csv 

Open in new window


(Get-ADUser -LDAPFilter "(sAMAccountName=$Name)" -Properties extensionAttribute12).extensionAttribute12

Open in new window

0
 
LVL 70

Accepted Solution

by:
Qlemo earned 250 total points
ID: 40030989
I'm pretty certain you don't want just to dump the content of that attribute. Instead you are interested in the user data, and so at least need the samAccountName. And, btw, you either need to provide a specific user ID, or a filter with Get-ADUser:
get-aduser -Filter * -properties extensionAttribute12 |
   ? { $_.samaccountname } |
   select samAccountName, extensionAttribute12 |
   export-csv c:\CustomAttr12.csv

Open in new window

0
 
LVL 29

Expert Comment

by:becraig
ID: 40030993
Qlemo are you saying that my command will dump the content of that attribute for all users  ?
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 40031009
Not for all users, but for users with that attribute set. And no info about the user itself.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Powershell help for creating accounts 283 88
Powershell PGP and SFTP 1 45
Move files based on file names? 8 66
Add Log to powershell Script 14 29
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
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…

739 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