SCRIPT TO DELETE A SECUNDARY EMAIL ADRESS
hi i need a powershell script to delete only a secundary smtp email adress from any 100 users in active directory example : @tech.com thanks. mcse 200x + mesaging 2000 2003 2007 2010
February 13th, 2011 11:18am

Try this here, tested and works you get some pipline errors but works fine. Get-Mailbox | foreach { for ($i=$_.EmailAddresses.Count;$i -ge 0; $i--) { $address = $_.EmailAddresses[$i] if ($address.SmtpAddress -like "*@target.local" ) { Write-host("Remove smtp adress: " + $address.AddressString.ToString() ) $_.EmailAddresses.RemoveAt($i) } } $_|set-mailbox } http://anewmessagehasarrived.blogspot.com/2008/06/remove-proxyaddresses-powershell-script.htmlJames Chong MCITP | EA | EMA; MCSE | M+, S+ Security+, Project+, ITIL msexchangetips.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
February 13th, 2011 12:05pm

thhis is good , but i have a problem , when pass 1000 results , give me a error: WARNING: By default only the first 1000 items are returned. To change the number of items returned, specify the parameter "-ResultSize". To return all items specify "-ResultSize Unlimited" (Note: Returning all items may take a very long time and consume a large amount of memory depending on the actual number of items). It is not recommended to store the results in a variable; instead pipe the results to another task or script to perform batch changes. mcse 200x + mesaging 2000 2003 2007 2010
February 14th, 2011 8:18am

Try this Get-Mailbox -resultsize unlimited | foreach { for ($i=$_.EmailAddresses.Count;$i -ge 0; $i--) { $address = $_.EmailAddresses[$i] if ($address.SmtpAddress -like "*@target.local" ) { Write-host("Remove smtp adress: " + $address.AddressString.ToString() ) $_.EmailAddresses.RemoveAt($i) } } $_|set-mailbox }
Free Windows Admin Tool Kit Click here and download it now
February 14th, 2011 8:42am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics