Manage Office365 Via PowerShell (Step 1. Connect to Office365)

The Microsoft’s Software as a Services (SaaS) offering is a set of different components, that I like to call building block, that sits on top of what is called Office365.
The basic components are:

  1. Office365 (Main Component to manage Domains, Users, Licenses, etc)
    1. Exchange Online
    2. SharePoint Online
    3. Skype for Business
    4. Office ProPlus
    5. Yammer

In this particular guide, we will be connecting to Office365 (the main building block) via PowerShell where we will be able to automate the licenses assignment, manage our domain or change the login name of our users.

To connect to Office we just need to follow three basic steps:

  1. Install the required software:
  2. Open the Windows Azure Active Directory Module: Search for the Windows Azure Active Directory Module for Windows PowerShell
  3. Connect to your Office365 Tenant
$UserCredential = Get-Credential
Connect-MsolService -Credential $UserCredential 

After running the last command you will see no response. Therefore, I suggest you to request any information to the Office365 servers to confirm the connection. For instance, you can do Get-MsolAccountSku to return your current Office365 subscriptions.



Force AAD Connect Synchronization Cycle

The scheduler will run by default run every 30 minutes. In some cases you might want to run a sync cycle in between the scheduled cycles or you need to run a different type.

Delta Sync Cycle
It could be that you have an urgent change which must be synchronized immediately which is why you need to manually run a cycle. If you need to manually run a cycle, then from PowerShell run:

Start-ADSyncSyncCycle -PolicyType Delta

Full Sync Cycle
If you have made one of the following configuration changes, you need to run a full sync cycle (a.k.a. Initial):

  • Added more objects or attributes to be imported from a source directory
  • Made changes to the Synchronization rules
  • Changed filtering so a different number of objects should be included (e.g. Adding a new OU to the filter)

If you have made one of these changes, then you need to run a full sync cycle so the sync engine has the opportunity to reconsolidate the connector spaces. To initiate a full sync cycle, run:

Start-ADSyncSyncCycle -PolicyType Initial