Solved

Power Shell Get-ADUser

Posted on 2014-04-29
8
1,332 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
 
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
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.

 
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 68

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 68

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

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

Question has a verified solution.

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

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
Set OWA language and time zone in Exchange for individuals, all users or per database.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now