Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 363
  • Last Modified:

export AD user attributes powershell

I have a CSV file with usernames, the field heading is samaccountname

I would like to be able to read in this CSV and export AD attributes to another CSV
0
cmatchett
Asked:
cmatchett
  • 6
  • 5
  • 2
  • +1
2 Solutions
 
Jon BrelieSystem ArchitectCommented:
Which AD attributes are you trying to export?
0
 
cmatchettAuthor Commented:
samaccountname, OfficePhone
0
 
becraigCommented:
import-module ac*
import-csv c:\file.csv | %  {$user = $_.samaccountname; Get-Aduser | select (whaevet objects you need) | export-csv c:\results.csv -nti}

Open in new window


Since I am not sure what attributes you are after here is a list:

http://social.technet.microsoft.com/wiki/contents/articles/12037.active-directory-get-aduser-default-and-extended-properties.aspx
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
cmatchettAuthor Commented:
becraig, i am getting


cmdlet Get-ADUser at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
0
 
becraigCommented:
This should work:

import-module ac*
import-csv c:\file.csv | %  {$user = $_.samaccountname; Get-Aduser -identity $user -properties * | select  Officephone, samaccountname | export-csv c:\result.csv -nti

Open in new window

0
 
Joshua GrantomSenior EngineerCommented:
Missing an ending brace "}" it was set to overwrite the CSV with each user
$users = import-csv c:\file.csv | % {$user = $_.samaccountname; Get-Aduser -identity $user -properties * | select  SamAccountName,Officephone} | export-csv c:\result.csv -nti

Open in new window

0
 
becraigCommented:
Thanks Joshua, did this on the phone, so no validation :~(
0
 
cmatchettAuthor Commented:
great work.  love experts exchange.
0
 
Joshua GrantomSenior EngineerCommented:
its alright. Also, is OfficePhone a valid attribute?

Usually there is just

telephoneNumber, mobile, otherTelephone, facsimileTelephoneNumber, homePhone, ipPhone, otherPager, otherMobile, otheripPhone, otherHomephone, and otherFacsimileTelephoneNumber...

Unless its an added attribute from exchange.

Also, if you could give credit to becraig, I just added a brace. At least give him most of it.
0
 
becraigCommented:
It is one of the extended properties, I think i provided a link in the first post that covers this.
0
 
cmatchettAuthor Commented:
sorry, what i meant to do was select multiple answers and select craigs as the best.

Yes officephone is the telephone attribute.

How can i undo my points scoring?  Can you go to a moderator and ask them to do it?
0
 
becraigCommented:
You can just file a request for attention, though I am ok to split the points.
0
 
cmatchettAuthor Commented:
request for attention filed
0
 
cmatchettAuthor Commented:
great work
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 6
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now