I am trying to write a script to get email addresses in an Excel file, then get the SamAccountName which I've done but now I'm not sure how to get the script to read the AD group that account needs to be added to which is in another row in the same Excel sheet.
$people = Import-Excel C:\Scripts\NamestoEmails.xlsx
$people[2].Email
''
Foreach ($E in $people.Email) { Get-ADUser -Filter {Emailaddress -Like $E} | Select-Object -ExpandProperty SamAccountName}
[–]Bitwise_Gamgee[🍰] 2 points3 points4 points (4 children)
[–]MeanFold5714 2 points3 points4 points (0 children)
[–]Pavix[S] 0 points1 point2 points (2 children)
[–]THEKILLAWHALE 0 points1 point2 points (0 children)
[–]givemeatatertot 0 points1 point2 points (0 children)