Powershell script to add users to A/D group from .csv using email address only?
Powershell script to add users to A/D group from .csv using email address only? Import-CSV "C:usersBalbahagwdesktoptest1.csv" | Foreach-Object { $aduser = Get-ADUser -Filter { EmailAddress -eq $_.'EmailAddress' } if( $aduser ) { Write-Output "Adding user $($aduser.SamAccountName) to groupname" Add-ADGroupMember -Identity tech-103 -Members $aduser } else { Write-Warning "Could not find user in AD with email address $($_.EmailAddress)" } } Script is working now, however it can't find the user in AD with the email address. The error message tells you precisely what went wrong. – Bill_Stewart Jun 29 at 19:54 You want -Members not -User. At a powershell prompt type: Get-Help Add-ADGroupMember -Detailed – EBGreen ...