- In order to script the connection to exchange online with mfa, you must first download the Microsoft.Exchange.Management.ExoPowershellModule.dll I assume you will have to periodically update the.
- Re: Unable to install Exchange Online PowerShell Module supports multi-factor authentication @Vasil Michev Question, now that IE is officially dead, how do we transition this functionality to the new Edge?
Today, Exchange Online is managed through PowerShell by creating a remote. This process does not use a dedicated local PowerShell module and has never.
- 3 Azure AD App Registration
- 4 Create Microsoft365 Groups
First Step is to Install PnP.Powershell Module and authenticate using Connect-PnPOnline to Sharepoint before we can run New-PnPMicrosoft365Group cmdlet. There are many different ways you can authenticate to Sharepoint using
Connect-PnPOnline. Two specific methods which we will see in this blog post, One method is to use
-UseWebLogin which does not work with
New-PnPMicrosoft365Group and Other One is using App Only Azure Active Directory which works fine with
New-PnPMicrosoft365Group. This is the authentication method we will be using today to complete our task.
To Install PnP.Powershell Module on your system. Open Powershell Console as an Administrator and Type below Command:
Lets see what happens when we use
-useWebLogin switch with
Connect-PnPOnline command. Open Powershell as Administrator, type below command and Press Enter. Make sure PnP.Powershell Module is installed on the system otherwise below commmand will not work.
A small window will pop-up on the screen, Enter your administrator credentials to authenticate to Sharepoint.
Now we will test
New-PnPMicrosoft365Group command. As you can see in below screenshot
New-PnPMicrosoft365Group cmdlet does not work with a WebLogin/Cookie based connection. Therefore we will use App based authentication using Azure Active Directory and then use
New-PnPMicrosoft365Group command to create Microosft 365 groups. In the next section, I will be creating and configuring an Azure App Registration for App based authentication.
To Create an App registration, Login on Azure Portal (https://portal.azure.com) -> Azure Active Directory -> Appregistrations and click on New registration.
Provide a Name of the Application, Select Who can use this application or access this API ? and click on Register.
Once the Application is registered, Click on Overview link and then copy the Client ID. Client ID will be used when we will connect to Sharepoint via
Next step is to provide minimum permissions to this app for our task. For this, click On API Permissions and then click on Add a Permission.
Click on Microsoft Graph on Request API Permissions Pane.
Click on Application Permissions
Microsoft Exchange Login
Search for Group and Provide Group.ReadWrite.All Permission.
Search for directory and Provide Directory.ReadWrite.All Permission.
Grant Admin Consent
Admin Consent Granted
Certificates & Secrets
Next Step is to create a self-signed certificate and upload it to the app PnP Powershell which we registered in Azure Active Directory and granted consent in previous steps. Let’s see how we can generate and upload the certificate.
For creating a self-signed certificate, I have used a script which you can copy from below Microsoft Docs Link: https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread.
Once you have copied the script and saved it in a .ps1 file. Use below command to generate a self signed certificate. Please note that the Date Format is YYYY-MM-dd. Change the Startdate and EndDate according to your certificate expiry requirements.
Generated SelfSignedCertifcate Folder looks on my system. You can choose any name for the Folder or Certificate.
Click on Certificates & Secrets Link in Azure AD App PnP Powershell and then click on Upload Certificate.
Select .cer file to upload.
Certificate .cer file / Public Key is uploaded.
For Creating Microsoft 365 Group(s), We need to gather few values which will be used to connect to sharepoint using
Connect-PnPonline command. Below are the values required for this command.
First connect to Sharepoint using
Connect-PnPOnline command using the command shown below:
Create one Microsoft 365 Group using New-PnPMicrosoft365Group without Team
Owners and Members of the group as we defined in our command.
Create one Microsoft 365 Group using New-PnPMicrosoft365Group with Team
Create Microsoft 365 Group with Sharepoint site and with connected Team. I am using the same example as above, the only difference is a switch added to the end of
Create Microsoft 365 Groups in bulk
For creating Microsoft365 groups in bulk, I have created a small script which you can use. You can copy the script from this blog post or download it from TechPress GitHub Page as well. Please find the link of Github page in the next section. Before you can use the script, there are some important points to note as given below:
Once you have a sample csv file created and variables populated in the powershell script. Lets run it to see how it goes. This is how my folder looks like:
– After dot sourcing the script, you can check more information about the script using get-help Create-M365GroupwithSPOSite