Connecting To Office 365 With PowerShell



Connecting your Office 365 tenant or Microsoft 365 tenant to PowerShell allows you to take greater control over your tenancy, using powerful commands and scripts to achieve your goals.

One example of how I have used PowerShell with Office 365, is to Batch delete multiple users at a time by using a CSV file, this is something that you can't achieve through The Office 365 admin portal.

Using PowerShell with Office 365 is designed for users with administrative privileges and should not be used by standard users.

The MSOnline PowerShell module enables you to use PowerShell to delete users, create users, assign licenses, and much much more.

To get started with PowerShell in Office 365 you will need to install some required modules in PowerShell.

Installing the MSOnline PowerShell module


  1. Open PowerShell
  2. Type the command "Install-Module MSOnline"
  3. You may be asked if you trust this repository, press "y" then press "enter"
  4. You may also be asked if you want to install nuget, if you see this type "y" then press "enter"
  5. The MSOnline module should then start installing.
  6. Once the module installation is complete you should be ready to run commands on Office 365 with PowerShell.

Depending on your system, additional dependencies may be required, if you are unable to successfully install the MSOnline module, please refer to the official Microsoft documentation for more information located at docs.microsoft.com/en-us/office365/enterprise/PowerShell/connect-to-office-365-powershell

Additional modules are available to extend the functionality of PowerShell and Office 365 / Microsoft 365, including the PowerShell module for AzureAD which you can use to do things such as change a user's job title, and create and manage users, applications, devices and Domains.
To learn more about the AzureAD PowerShell module visit docs.microsoft.com/en-us/powershell/module/Azuread/


Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
Icons made by Smashicons from www.flaticon.com is licensed by CC 3.0 BY

Was this helpful?

Yes No


Comments