locked
PowerShell -EmailAddressPolicyEnabled $true while setting PrimarySmtpAddress RRS feed

  • Question

  • Hi,

    I have a problem when setting the PrimarySmtpAddress through PowerShell/C#. Our standard email addresses in the forest is somebody@company.com but our is somebody@company.dk.

    I'm able to set the smtp address but it's failing when setting the EmailAddressPolicyEnabled to true. Logical I can see why ;-), but I'm still able to enable it through the EMC. Is there any way to do it through code?

    My code:

    <snip>

    psScript.AppendLine("[bool](Get-User -Identity "somebody" -DomainController dc.somewhere.com | Enable-Mailbox -Alias  "somebody" -Database "ExchDB"  -PrimarySmtpAddress "somebody@company.dk");

    psScript.AppendLine("Set-Mailbox -Identity "somebody"-EmailAddressPolicyEnabled $true");

    </snip>

    Thanks, Morten

    Tuesday, July 30, 2013 6:52 PM

Answers

  • The EmailAddressPolicy ist enabled by Default if you mailenable a Mailuser.

    If you wish to Change the PrimarySmtpAddress to somebody@company.dk you have to disable the policy (EmailAddressPolicyEnable -eq $False) after the Mailbox is mailenabled.


    Viele Grüsse Georg

    • Marked as answer by MorFahr Wednesday, August 7, 2013 12:23 PM
    Wednesday, August 7, 2013 12:14 PM

All replies

  • So you have an email address policy that applies to the user that has a Primary Reply address of _@company.dk and you want to be sure that this policy is applied to the user (EmailAddressPolicyEnable -eq $True) but you want to modify the Primary Reply address on the user to _@company.com?

    Why not just modify the Email Address Policy if applying to all users? Or create a new policy with this value to apply to 'select' users?

    Otherwise, you probably don't want to do this because it won't take much for the Primary Reply to revert on its own.

    Monday, August 5, 2013 6:01 PM
  • Thanks,

    "

    So you have an email address policy that applies to the user that has a Primary Reply address of _@company.dk and you want to be sure that this policy is applied to the user (EmailAddressPolicyEnable -eq $True) but you want to modify the Primary Reply address on the user to _@company.com?"

    Actually I don't want to change anything but otherwise yes.

    I want to set everything through code and enable the email policy afterwards without updating the primary smtp address. (It actually doesn't make sense but nevertheless I'm able to do this through the EMC but not through code) 

    When applying the default policy through the EMC, the primary address isn't - and shouldn't be - updated, which means nothing actually changes even though the default email address policy (containing the _@company.com address) is enabled. When I create a new user through the console it automatically gets the _@company.com address.

    I guess my question is why I can apply the default policy through EMC but not through code? A bug perhaps?

    Wednesday, August 7, 2013 10:40 AM
  • The EmailAddressPolicy ist enabled by Default if you mailenable a Mailuser.

    If you wish to Change the PrimarySmtpAddress to somebody@company.dk you have to disable the policy (EmailAddressPolicyEnable -eq $False) after the Mailbox is mailenabled.


    Viele Grüsse Georg

    • Marked as answer by MorFahr Wednesday, August 7, 2013 12:23 PM
    Wednesday, August 7, 2013 12:14 PM
  • Hi Georg,

    Thanks that's also what I found out. Just find it strange that I'm able to enable the policy through the console afterwards without any changes. Never mind, it works but still a bit strange...

    Thanks all

    Morten

    Wednesday, August 7, 2013 12:22 PM
  • Sometimes you have to wait upon AD Replication finished or Refresh if you use EMC. EMC could be slow.

    Things will better if you try thru EMS.


    Viele Grüsse Georg

    Wednesday, August 7, 2013 12:29 PM