如何使用PowerShell导入samaccountname的CSV并导出用户和组的列表。
Import-Csv C:\TEMP\test.csv |
ForEach-Object -pv user {
Get-AdUser -filter "samaccountname -eq '$($_.username)'"
} |
Get-ADprincipalGroupMembership |
Select-Object @{n='samaccountname';e={$user.samaccountname}}, name |
Export-Csv -Path C:\TEMP\testresult.csv -NoTypeInformation