0

I would like output from the following snippet as a text file. How do I accomplish this?

$users = Import-Csv Y:\Temp\list2.csv

foreach ($user in $users) {
    Get-QADUser -lastname $user.lastname -firstname $user.firstname | select firstname,lastname,mobile,primarysmtpaddress,logonname 
}
Sune
  • 3,080
  • 16
  • 53
  • 64

1 Answers1

1
Import-Csv Y:\Temp\list2.csv | foreach {
    Get-QADUser -lastname $_.lastname -firstname $_.firstname | select firstname,lastname,mobile,primarysmtpaddress,logonname 
} | Export-Csv c:\list3.csv
Shay Levy
  • 121,444
  • 32
  • 184
  • 206
  • Thanks, missed that. Updated now. – Shay Levy Nov 07 '12 at 11:04
  • Excellent! Thank you very much Shay! Do you mind explaining why your pipe didn't process until all the foreach was done? – Sune Nov 07 '12 at 11:32
  • 1
    I'm using a streamlined version (as opposed to the foreach loop that cannot pipe to another command) where the cmdlet outputs its objects as soon as it has finished processing them, until they find their way to the file. – Shay Levy Nov 07 '12 at 11:37
  • 1
    See this post: http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2010/12/09/Quick-Tip-Out_2D00_File-and-IOPs-Position-matters.aspx – Shay Levy Nov 07 '12 at 11:41