Code Dump: Change UPN for all members of an AD Group

$ADGROUP="TEST"
$OLDUPN="@OLDDOMAIN.COM"
$NEWUPN="@NEWDOMAIN.COM"

$GRPMEM=Get-ADGroupMember $ADGROUP

Get-ADGroupmember $ADGROUP | ForEach-Object {
$USER=Get-ADUser $_.samaccountname
$UPN = $USER.UserPrincipalName.Replace($OLDUPN,$NEWUPN)
Set-ADUser $USER.samaccountname -UserPrincipalName $UPN
}