PowerShell Modules / CMDLETs – Connecting to Microsoft 365 Services

Installing SharePoint Online PowerShell module
Installing SharePoint Online PowerShell module

Hi All,

Greetings for the day!!!

In this article I am discussing how to connect with different PowerShell modules which work with Microsoft 365 environment

PnP PowerShell

  • For using PnP PowerShell, we need to install module PnP.PowerShell
Install-Module PnP.PowerShell

PowerShell terminal displaying the command 'Install-Module PnP.PowerShell' and a prompt regarding installation from an untrusted repository.
figure: Installing PnP.PowerShell module
  • Once PnP.PowerShell module is installed we are ready to execute PnP.PowerShell CMDLETS
  • Lets connect SharePoint online site using Connect-PnPOnline
PS C:\> $ClientID = "768437d9-957a-4a5e-b91a-f68213bf6d33"
PS C:\> $SiteURL = "https://knowledgejunction1.sharepoint.com/"
PS C:\> Connect-PnPOnline -Url $SiteURL -Interactive -ClientId $clientId
PS C:\> Get-PnPSite

Url                                                     CompatibilityLevel
---                                                     ------------------
https://knowledgejunction1.sharepoint.com               15

PS C:\>

Screenshot of a PowerShell command line interface displaying commands to connect to a SharePoint site using the PnP PowerShell module.
figure: After installing PnP.PowerShell module, executing PnP Powershell CMDLETES

Exchange Online

  • We have “ExchangeOnlineManagement” PowerShell module to use the Exchange Online PowerShell CMDLETs
  • We can install “ExchangeOnlineManagement” PowerShell module using Install-Module PowerShell CMDLET

PS C:\Windows\System32> Install-Module -Name ExchangeOnlineManagement -Force

  • Once we have successfully installed PowerShell module “ExchangeOnlineManagement“, we are ready to execute the Exchange Online PowerShell CMDLETs
  • In below example, we are connecting to Exchange Online using “Connect-ExchangeOnline” PowerShell CMDLET

PS C:\Windows\System32> Connect-ExchangeOnline

A screenshot of a PowerShell terminal showing commands and descriptions related to the Exchange Online V3 module, emphasizing improved authentication methods and cmdlet functionalities.
figure: Connecting to Exchange Online

SharePoint Online

  • To execute SharePoint online PowerShell CMDLETs we need install SharePoint Online PowerShell module – Microsoft.Online.SharePoint.PowerShell

PowerShell command line interface showing installation and import commands for the Microsoft Online SharePoint PowerShell module.
figure: Installing SharePoint Online PowerShell module
  • Once we successfully installed SharePoint Online PowerShell module we are ready to execute the SharePoint online PowerShell CMDLETs
  • Lets connect SharePoint site using SharePoint Online PowerShell CMDLET – Connect-SPOService
Screenshot showing PowerShell commands for connecting to SharePoint Online and fetching site information.
figure: Successfully execute the Connect-SPOService CMDLET

Microsoft Teams

  • To execute Microsoft Teams PowerShell CMDLETs we need to install the Microsoft Teams PowerShell module – MicrosoftTeams
  • We can verify if MicrosoftTeams module is installed or not using Get-Module CMDLET as

PS C:\> Get-Module -Name MicrosoftTeams -ListAvailable

    Directory: C:\Users\u1086350\Documents\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     7.0.0                 MicrosoftTeams                      Core,Desk {Add-TeamChannelUser, Add-TeamUser, Con…

Command prompt showing available PowerShell modules for Microsoft Teams, including version details and exported commands.
figure: Verifying if Microsoft Teams PowerShell module is installed or not
  • Once we have Microsoft Teams PowerShell module in place, we can connect to Microsoft Teams and execute Microsoft Teams PowerShell CMDLETs
  • We will connect Microsoft Teams using PowerShell CMDLET – Connect-MicrosoftTeams as

PS C:\> Connect-MicrosoftTeams

Account                                    Environment Tenant                               TenantId
-------                                    ----------- ------                               --------
prasham@knowledgejunction1.onmicrosoft.com AzureCloud  6b38e1c3-a1fe-40cc-8b93-a4159a50592c 6b38e1c3-a1fe-40cc-8b93-a4…

PowerShell command line interface displaying the command to connect to Microsoft Teams using Connect-MicrosoftTeams.

  • As we successfully connects to Microsoft Teams, we are ready to execute the Microsoft Teams PowerShell CMDLETs
  • Lets get all Teams in our tenant using PowerShell CMDLET – Get-Team as

PS C:\> Get-Team

GroupId                              DisplayName        Visibility  Archived  MailNickName       Description
-------                              -----------        ----------  --------  ------------       -----------
71626482-1105-47ff-b01b-9e64519ea1fc LIFE IS BEAUTIFUL  Public      False     lifeisbeautiful    LIFE IS BEAUTIFUL

A screenshot showing a PowerShell command to retrieve a list of Teams in a Microsoft 365 environment, displaying Group ID, Display Name, Visibility, Archived status, Mail Nickname, and Description.
figure: Executing Microsoft Teams PowerShell CMDLET – Fetching all teams from tenant – Get-Teams

REFERENCES

Thanks for reading ! Stay tuned on Microsoft 365 Junction for all updates, issues, solutions and tutorials

HAVE a FANTASTIC LEARNING AHEAD!!! LIFE IS BEAUTIFUL 🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL. ENJOY THE WHOLE JOURNEY :) Founder of Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

You may also like...

4 Responses

  1. June 11, 2025

    […] PowerShell Modules / CMDLETs – Connecting to Microsoft 365 Services – https://microsoft365junction.com/2025/06/09/powershell-connecting-to-microsoft-365-services/ […]

  2. July 25, 2025

    […] PowerShell Modules / CMDLETs – Connecting to Microsoft 365 Services – https://knowledge-junction.in/2025/06/09/powershell-connecting-to-microsoft-365-services/ […]

  3. February 9, 2026

    […] PowerShell Modules / CMDLETs – Connecting to Microsoft 365 Services […]

  4. April 20, 2026

    […] PowerShell Modules / CMDLETs – Connecting to Microsoft 365 Services – https://knowledge-junction.in/2025/06/09/powershell-connecting-to-microsoft-365-services/ […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.