从foreach循环导出数据(Get-QADUser)

时间:2012-11-07 09:36:38

标签: powershell foreach quest

我希望从以下代码段输出作为文本文件。我该如何做到这一点?

$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 
}

1 个答案:

答案 0 :(得分: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