0 votes

Hi,

For our students we use the ForwardingSMTPAddress property to forward their email to an external address like this:

Set-Mailbox -Identity “mailboxalias” -DeliverToMailboxAndForward $true -ForwardingSMTPAddress externaladdress@test.com

To remove it we use:

Set-Mailbox -Identity “mailboxalias” -DeliverToMailboxandforward $False -ForwardingSMTPAddress $Null -ForwardingAddress $Null

Is there any way to accomplish this in Adaxes?

W could use a virtual property an have a business rule for user change perhaps?

/Jonas

by (50 points)
0

Hello Jonas,

Yes, you can provide the forwarding SMTP address in a virtual property, and a Business Rule triggered after updating a user will set the forwarding address. We've asked our script guys to write a script that can be used in such a Business Rule. We'll update this topic as soon as they come up with something.

1 Answer

0 votes
by (216k points)
selected by
Best answer

Jonas,

To implement what you want, you can create a Business Rule triggered after updating a user. To pass the external forwarding address to the Business Rule, you can use an Adaxes virtual property that can store text values, for example, CustomAttributeText1. If the virtual property that you chose is modified and not empty, the Business Rule will enable forwarding to the specified address, otherwise, if the property was cleared, the Business Rule will disable forwarding.

To create such a Business Rule:

  1. Create a new Business Rule.

  2. On the 2nd step of the Create Business Rule wizard, select User and After Updating a User.

  3. On the 3rd step, add the Run a program or PowerShell script action and paste the following script in the Script field. This script enables forwarding to an external SMTP address.

     $exchangeServer = "ExchangeServer.domain.com" # TODO: modify me
     $smtpAddress = "%adm-CustomAttributeText1%" # TODO: modify me
    
     # Create a remote PowerShell session to Exchange Server
     $session = New-PSSession -configurationname Microsoft.Exchange -connectionURI http://$exchangeServer/PowerShell
     Import-PSSession $session -DisableNameChecking -AllowClobber
    
     # Enable forwarding
     Set-Mailbox -Identity "%distinguishedName%" -DeliverToMailboxAndForward $true -ForwardingSMTPAddress $smtpAddress
    
     # Close the remote session and free up resources
     Remove-PSSession $session
    
  4. In the script, modify the following to match your environment:

    • $exchangeServer - specifies the fully qualified domain name (FQDN) of your Exchange Server.
    • $smtpAddress - specifies a value reference for the property that will be used to pass the external address. For example, if you want to use CustomAttributeText1, specify %adm-CustomAttributeText1%.
  5. Enter a short description for the script and click OK.

  6. Now, you need to add a condition when the script will be executed. Right-click the action that you've just added and select Add Condition.

  7. Select the If <property> <changed> condition type.

  8. In the <property> drop-down list, select Show all properties and select the virtual property that you chose, e.g. CustomAttributeText1.

  9. Select has changed.

  10. Click OK.

  11. Also, the script to enable forwarding should be launched only when a forwarding address is specified, that is, when the virtual property is not empty. Right-click the action that you've added and select Add Condition again.

  12. Select the If <property> <relation> <value> condition type.

  13. In the <property> drop-down list, select Show all properties and select the virtual property that you chose, e.g. CustomAttributeText1.

  14. Select is not empty.

  15. Click OK.

  16. Now, you need to add an action to disable forwarding. Click the Add action to a new set link.

  17. Select the Run a program or PowerShell script action and paste the following script in the Script field. This script disables forwarding to an external SMTP address.

     $exchangeServer = "ExchangeServer.example.com" # TODO: modify me
    
     # Create a remote PowerShell session to Exchange Server
     $session = New-PSSession -configurationname Microsoft.Exchange -connectionURI http://$exchangeServer/PowerShell
     Import-PSSession $session -DisableNameChecking -AllowClobber
    
     # Disable forwarding
     Set-Mailbox -Identity "%distinguishedName%" -DeliverToMailboxAndForward $true -ForwardingSMTPAddress $NULL
    
     # Close the remote session and free up resources
     Remove-PSSession $session
    
  18. In the script, modify the following to match your environment:

    • $exchangeServer - specifies the fully qualified domain name (FQDN) of your Exchange Server.
    • $smtpAddress - specifies a value reference for the property that will be used to pass the external address.
  19. Enter a short description for the script and click OK.

  20. Now, you need to add a condition when the script will be executed. Right-click the action that you've just added and select Add Condition.

  21. Select the If <property> <changed> condition type.

  22. In the <property> drop-down list, select Show all properties and select the virtual property that you chose, e.g. CustomAttributeText1.

  23. Select has changed.

  24. Click OK.

  25. Also, the script to enable forwarding should be launched only when a forwarding address is not specified, that is, when the virtual property is empty. Right-click the action that you've added and select Add Condition again.

  26. Select the If <property> <relation> <value> condition type.

  27. In the <property> drop-down list, select Show all properties and select the virtual property that you chose, e.g. CustomAttributeText1.

  28. Select is empty.

  29. Click OK. You should receive something like this:

  30. Finish creation of the Business Rule.

For information on how to add the property to the page for editing users, see step 6 in the Customize Forms for User Creation and Editing Tutorial.

Since a name like CustomAttributeText1 will not tell much to your users about the function of the property, you can also configure Adaxes to use a different display name for the property.

0

Works like a charm. Thanks!

Related questions

0 votes
0 answers

Hello, Why Adaxes cannot manage email forwarding configured as SMTP address? It works only with email forwarding when forwarding is done to mail contact or other mailbox ... frustrated team members because forwarding exists but is not represented in Adaxes...

asked Dec 6, 2018 by DLe (760 points)
0 votes
1 answer

Hallo, As a part of my custom command I'd like to create forward from a mailbox to an external SMTP. Unfortunately I cann't use below script because of security policy: ... it by myself but I stuck on bing contact for forward. Could you please help me?

asked Aug 28, 2015 by axmaster (510 points)
0 votes
1 answer

I need set, or verify, that all of my users have the same primary email alias suffix. Several years ago, we rebranded to a new internet presence. All users yhave both ... really a very great answer. Looking for automation, and we are an Adaxes supported shop.

asked May 14, 2021 by IanMcLaws (20 points)
0 votes
1 answer

Hi, we need to create some form (or custom command?) so managers of distribution groups can add/remove/change alias address. Primary and secondary. Distribution groups are ... contains list of current aliases with possibility to edit them... Thank you Sebela

asked Nov 18, 2019 by KIT (960 points)
0 votes
1 answer

I try to establish a custom command for MS Teams call forwarding. I have created a paramter for the calltarget. But it looks like it has not the right format &lt;br&gt; . ... &lt;ScriptBlock&gt;, &lt;No file&gt;: line 28 How do I modify the paramater? Thanks.

asked Oct 18, 2023 by boris (550 points)
3,588 questions
3,277 answers
8,303 comments
548,093 users