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

x
?
Solved

powershell script to read in user's email address then generate a csv file with samaccount, and other attributes

Posted on 2012-03-27
9
Medium Priority
?
3,679 Views
Last Modified: 2012-04-24
Hi Guys,

I need  a PS to read in a text file that contains bunch user's email address then out put name, samaccountname, and extensionattribute9 to a csv file.

Please help!

Thanks
0
Comment
Question by:fireburn11
  • 4
  • 3
  • 2
9 Comments
 
LVL 14

Expert Comment

by:athomsfere
ID: 37771695
I personally like Quests Active Directory tools

Here is a script using QAD

Get-Content 'ImportPath' | ForEach-Object
	{
	Select-Object Name, SamAccountName, ExtensionAttribute9 | Export-Csv 'ExportPath'
	}

Open in new window

0
 

Author Comment

by:fireburn11
ID: 37771724
Hi Ahomsfere,

Is there a get-qaduser missing in there?
0
 

Author Comment

by:fireburn11
ID: 37771737
i dont think the script is working, there is no variable declared..
0
New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

 
LVL 27

Expert Comment

by:KenMcF
ID: 37772139
Try this

$Users = get-content c:\temp\emailaddresses.txt
$Users | foreach {
    Get-QADUser -Email $Mail
} | Select samaccountname, mail | Export-Csv c:\temp\mailtest.csv -NoTypeInformation
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 37772145
had a typo


$Users = get-content c:\temp\emailaddresses.txt
$Users | foreach {
    Get-QADUser -Email $_
} | Select samaccountname, mail | Export-Csv c:\temp\mailtest.csv -NoTypeInformation
0
 
LVL 14

Expert Comment

by:athomsfere
ID: 37772244
Sorry, yes I forgot to include the variable / user:

Get-Content 'ImportPath' | ForEach-Object
	{
         Get-QADUser -Email $_ | `
	Select-Object Name, SamAccountName, ExtensionAttribute9 | Export-Csv 'ExportPath'
	}

Open in new window

0
 
LVL 27

Expert Comment

by:KenMcF
ID: 37772274
@athomsfere

your CSV file will be overwritten with every user, so you will only get the results for the last user in the CSV file.
0
 

Author Comment

by:fireburn11
ID: 37774389
well, actually, that is what i try to avoid, I need the csv file to include all user's selected attributes.

Thanks
0
 
LVL 27

Accepted Solution

by:
KenMcF earned 1500 total points
ID: 37774414
@fireburn11

Look at what I had posted before, I think this will get you what you want. Just change the input file and export file location



$Users = get-content c:\temp\emailaddresses.txt
$Users | foreach {
    Get-QADUser -Email $_
} | Select samaccountname, mail | Export-Csv c:\temp\mailtest.csv -NoTypeInformation
0

Featured Post

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
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…

971 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