Office 365 Azure AD Connect assigning .onmicrosoft.com to synced users

When Azure AD Connect it configure to sync ad account to Azure AD/Office 365 it assigns the login name as the AD UPN (as expected), but it won’t assign that same UPN as the default email address – instead it assign a @mydomain.onmicrosoft.com as the primary email address.

to correct this we can use the Synchronization rules editor, which is installed together with the Azure AD Connect (Download Link)

In Synchronization rules editor, switch the direction tabs to outbound rules.
select the rule called “Out to ADD – UserExchangeOnline”, click edit and accept the option to disable and clone the rule (this will create a rule called ““Out to ADD – UserExchangeOnline – Cloned” that can be modified.

Change the precedence to 50

go to transformations, and Scroll down till you find the “Target Attribute” of “ProxyAddresses”
Change the FlowType to “Expressions” and enter the following in the source:

Now resync the users and the primary email address should be changed

Sources: https://rscc.co.uk/solution-office-365-assigning-onmicrosoft-com-addresses-used-aad-connect/

Remove password expiration Office 365

Remove password expiration Office 365

I wrote this powershell script to remove password expiration for all users, so that the users password not expires

Password_expiration.ps1

Change Retention Policy – Office 365

Change Retention Policy – Office 365

I wrote this powershell script to remove the Retention Policy that delete all emails in Users Deleted Items folder that are older then 30 days

Retention_Policy.ps1

Create office 365 mail relay connector

Create office 365 mail relay connector

go to https://outlook.office365.com/ecp/ login as global administrator

step 1: click Mailflow
step 2: click Connectors
step 3: click Add

Office365AddRelayConnector1

step 4: Give the connector a name (eg. AllowRelay)
step 5: Select On-Premise
step 6: Select Restrict domains by IP addresses
step 7: Set sender domain to *
step 8: Set sender ip to your own Wan ip/public ip (Only static ips is allowed)
step 9: Set Accepted domains to your office 365 domain

Office365AddRelayConnector2

now you can use your own mx record eg. youdomain-com.mail.protection.outlook.com as relay server/smarthost without login, and on port 25
Source: http://technet.microsoft.com/en-us/library/dn554323.aspx