How to Get SharePoint Groups using PowerShell in SharePoint Online

Prerequisites:

SharePoint Online Management Shell: https://www.microsoft.com/en-us/download/details.aspx?id=35588

PnP – PowerShell Cmdlets: https://github.com/officedev/pnp-powershell/releases

PowerShell Script:

Open SharePoint Online Management Shell and execute the following script.

  1. ## Connects to a SharePoint Site  
  2. Connect-SPOnline -Url https://c986.sharepoint.com -Credentials (Get-Credential)  
  3.   
  4. ## Returns all groups  
  5. Get-SPOGroup  
  6.   
  7. ## Return a specific group  
  8. Get-SPOGroup -Identity Visitors  
  9.   
  10. ##Disconnects the context  
  11. Disconnect-SPOnline