Solved

Power Shell Get-ADUser

Posted on 2014-04-29
8
1,395 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
  • 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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 69

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 69

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
A procedure for exporting installed hotfix details of remote computers using powershell
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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