I have a mail variable with content like this
if ($user -eq 'abc') {$mail += 'abc@ae.com;'}
elseif ($user -eq 'efg') {$mail += 'efg@ae.com;'}
elseif ($user -eq 'hij') {$mail += 'hij@ae.com;'}
elseif ($user -eq 'klm') {$mail += 'klm@ae.com;'}
Now the $mail variable will have content like this
abc@ae.com;klm@ae.com;abc@ae.com;hij@ae.com;klm@ae.com
How do i remove the duplicate mail from $mail variable. tried the below but no luck.
$mail = $mail | select -unique
$mail | sort | Get-Unique