Solved

Power Shell Get-ADUser

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

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 28

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 28

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 28

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Synchronize a new Active Directory domain with an existing Office 365 tenant
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

19 Experts available now in Live!

Get 1:1 Help Now