Hi Guy's,
I've found a script and modified it so i can specify which smtp addresses to remove. The trouble im having is this script removes all the smtp addresses rather than one ones i specify in my input file. Can about help as I'm not getting any error messages when i run the script so its hard to troubleshoot.
# User provided list of mailboxes
$mailbox = Get-Content -Path C:\usermailboxes.csv
#Domains to remove from user account
$domains = Get-Content -Path C:\domains.txt
foreach($domain in $domains)
{
Write-Host "Processing domain" $domain -BackgroundColor Yellow
foreach($item in $mailbox)
{
$item = Get-Mailbox -Identity $item
Write-Host "Now working on mailbox" $item -BackgroundColor Green
for($i=($item.EmailAddresses.count)-1; $i -ge 0; $i--)
{
$address=$item.EmailAddresses[$i]
$addressString=$address.addressString
if($addressString -like "midas-kapiti.com")
{
$item.EmailAddresses.removeat($i)
}
}
$item |set-mailbox -EmailAddresses $mailbox.EmailAddresses
}
}
Many thanks guys & gals and appreciate any suggestions.
Regards
ScriptNoob