?
Solved

Power Shell Get-ADUser

Posted on 2014-04-29
8
Medium Priority
?
1,537 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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 1000 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 1000 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

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

771 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