I currently use the below script to add users to a group by SAMAccountName. I have a file that contains UPNs instead however, and this does not work. How can I modify the script to work with UPNs instead of SAMAccountName?
$Users = Get-Content UserList.txt
ForEach ($User in $Users)
Add-ADGroupMember -Identity 'GroupName' -Members $Users