none
Question removing old SMTP addresses RRS feed

  • Question

  • Hi,

    I have about 183 smtp(proxy)addresses on a PublicFolder in my Exchange 2007 environment that I would like to remove. I used the set-mailpublicfolder -identity "\root\sub\" -EmailAddresses @{remove='1.1.nl, 1.1.at'} so on and so forth. These scripts dont work because the "-EmailAddresses parameter seems to be unknown.

    Any idea on how to remove 183 PF email addresses from a CSV or just a normal commandwise option?

    Best regards,

    Sebastiaan


    Wednesday, June 17, 2015 2:28 PM

Answers

  • Hi,

    Please refer to the following steps:

    1. Set the email address policy to false.

    Set-mailpublicfolder -Identity "\root\sub\" –EmailAddressPolicy $false

    2. Set the email address for this public folder according to email address policy, this step will remove all other SMTP addresses.

    Set-mailpublicfolder -Identity "\root\sub\" –EmailAddresses Alias@domain.com

    3. Then enable the email address policy.

    Set-mailpublicfolder -Identity "\root\sub\" –EmailAddressPolicy $true

    Check with this command.

    Get-MailPublicFolder -Identity "\root\sub\" | fl EmailAddresses

    Best Regards.


    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com

    Lynn-Li
    TechNet Community Support

    • Marked as answer by Sebastiaan R Thursday, June 18, 2015 12:35 PM
    Thursday, June 18, 2015 2:51 AM
    Moderator
  • Removing the policy and re-applying it is not going to harm email addresses that are outside the policy - it will only ensure that the email address policy applies to the folder after the work is complete.  In fact, removing it is only going to allow you to apply the addresses applied outside the policy (without worrying about whether you included ones from the policy), so those steps are only being made to allow the middle step to run successfully every time.

    Now, the middle command will delete all email addresses that are not included in the list you give, so if you leave out any addresses that you want the public folder to have, they will be hosed.  So you can run your set-mailpublicfolder -identity "\root\sub\" -EmailAddresses @{remove='1.1.nl, 1.1.at'} command to remove the bad ones without causing undue issues.

    How many addresses will you leave on this public folder?  Would it be easier to remove the 183 or apply the remaining ones?

    Something else you may consider is to catch the full list of addresses in a variable, remove those you want removed (using a text file as input), then apply that as your list of email addresses, as follows:

    $BadAddresses = Get-Content BadAddresses.txt
    Set-MailPublicFolder -Identity "\root\sub\" –EmailAddressPolicy $false
    $Addresses = (Get-MailPublicFolder -Identity "\root\sub\").EmailAddresses
    $BadAddresses | % { $Addresses.Remove($_) }
    Set-MailPublicFolder -Identity "\root\sub\" –EmailAddresses $Addresses
    Set-MailPublicFolder -Identity "\root\sub\" –EmailAddressPolicy $true
    Get-MailPublicFolder -Identity "\root\sub\" | fl EmailAddresses

    In this, you can also add error handling on the remove statement ($BadAddresses | % { $Addresses.Remove($_) }) - it will return $False if it fails.


    Will Martin ...
    -join ('77696c6c406d617274696e2d66616d696c6965732e6f7267' -split '(?<=\G.{2})' | ? { $_ } | % { [char][int]"0x$_" })


    Thursday, June 18, 2015 11:46 AM

All replies

  • Hi,

    Please refer to the following steps:

    1. Set the email address policy to false.

    Set-mailpublicfolder -Identity "\root\sub\" –EmailAddressPolicy $false

    2. Set the email address for this public folder according to email address policy, this step will remove all other SMTP addresses.

    Set-mailpublicfolder -Identity "\root\sub\" –EmailAddresses Alias@domain.com

    3. Then enable the email address policy.

    Set-mailpublicfolder -Identity "\root\sub\" –EmailAddressPolicy $true

    Check with this command.

    Get-MailPublicFolder -Identity "\root\sub\" | fl EmailAddresses

    Best Regards.


    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com

    Lynn-Li
    TechNet Community Support

    • Marked as answer by Sebastiaan R Thursday, June 18, 2015 12:35 PM
    Thursday, June 18, 2015 2:51 AM
    Moderator
  • Hi,

    Thanks for the reply. If I do that won't I destroy healthy SMTP addresses which are set without the email address policy? There is no script or tool available to remove a specified list of SMTP addresses?

    Thanks!

    Best regards,

    Sebastiaan

    Thursday, June 18, 2015 6:46 AM
  • Removing the policy and re-applying it is not going to harm email addresses that are outside the policy - it will only ensure that the email address policy applies to the folder after the work is complete.  In fact, removing it is only going to allow you to apply the addresses applied outside the policy (without worrying about whether you included ones from the policy), so those steps are only being made to allow the middle step to run successfully every time.

    Now, the middle command will delete all email addresses that are not included in the list you give, so if you leave out any addresses that you want the public folder to have, they will be hosed.  So you can run your set-mailpublicfolder -identity "\root\sub\" -EmailAddresses @{remove='1.1.nl, 1.1.at'} command to remove the bad ones without causing undue issues.

    How many addresses will you leave on this public folder?  Would it be easier to remove the 183 or apply the remaining ones?

    Something else you may consider is to catch the full list of addresses in a variable, remove those you want removed (using a text file as input), then apply that as your list of email addresses, as follows:

    $BadAddresses = Get-Content BadAddresses.txt
    Set-MailPublicFolder -Identity "\root\sub\" –EmailAddressPolicy $false
    $Addresses = (Get-MailPublicFolder -Identity "\root\sub\").EmailAddresses
    $BadAddresses | % { $Addresses.Remove($_) }
    Set-MailPublicFolder -Identity "\root\sub\" –EmailAddresses $Addresses
    Set-MailPublicFolder -Identity "\root\sub\" –EmailAddressPolicy $true
    Get-MailPublicFolder -Identity "\root\sub\" | fl EmailAddresses

    In this, you can also add error handling on the remove statement ($BadAddresses | % { $Addresses.Remove($_) }) - it will return $False if it fails.


    Will Martin ...
    -join ('77696c6c406d617274696e2d66616d696c6965732e6f7267' -split '(?<=\G.{2})' | ? { $_ } | % { [char][int]"0x$_" })


    Thursday, June 18, 2015 11:46 AM
  • Thanks,

    This seems to be what we need.

    Regards,

    Sebastiaan

    Thursday, June 18, 2015 12:34 PM