Wednesday 30 June 2021

How To connect Exchange online through powershell if MFA is enabled

 You have to first download "Microsoft Exchange Online Power shell Module" from your exchange admin center portal (https://outlook.office.com/ecp/



then you have to open the "Microsoft Exchange Online Power shell Module" and you should get the window like below.


Then you have to use the command (Connect-EXOPSSession -UserPrincipalName AdminUser@domain.com) in Microsoft Exchange Online Power shell Module.



then it should pop up for the credentials and also for the second factor authentication.


Friday 25 June 2021

Get Office 365 users with a specific license

First we have to connect MSOLService through powershell.

Connect-MsolService

Then get the list of available licenses with the following command.

Get-MsolAccountSku

then we can use the following command to Get the users with a specific license

Get-MsolUser -MaxResults 200000 | Where-Object {($_.licenses).AccountSkuId -match "p:ems"} >c:\pathc\EMSUsers.CSV