If you’re like me, then you tend to find yourself wanting to automate as much as possible, or at least be able to work with sets of data in a way that quickly allows you to get to the root of an issue rather than clicking through endless screens of information.
In case you were curious, Office 365 makes use of Azure Active Directory behind the scenes for user managment. As Azure Active Directory is an enterprise resource for identity management for cloud hosted applications, Microsoft has gone to great length to create several interfaces to it. Granted, I could just use a REST call through the Microsoft Graph API to create or delete a user through a POST command, but I can also use PowerShell from a Windows based device.
For user management, our first step is to download the appropriate PowerShell Module. This can be done simply by installing the module through PowerShell running
install-module -name azuread
This will install the PowerShell module specifically for Azure AD and allow you to manage your users. From there before you can make any changes to your user base you’ll need to authenticate. An easy way to do this is as follows:
$creds = get-credential -credential
connect-azure-ad -credential $creds
From there you can parse your users and make modifications to your hearts desire. Running “Get-AzureADUser” enumerates all user objects. Load it into an array and work with the users as you wish.
Nevertheless, for more on this topic, check out the Microsoft Support docs over at:
https://docs.microsoft.com/en-us/office365/enterprise/powershell/connect-to-office-365-powershell