I'm pretty new to PowerShell. What's the best command to run to get a list of user permissions on a SP Online site?

Thanks in advance.

1 Answer 1


Use the below PowerShell Script:

#SPO-specific cmdlets require sharepoint-online module

Install-Module -NameMicrosoft.Online.SharePoint.PowerShell

$ServiceURL ="https://enterprise-admin.sharepoint.com"

$URL = "https://enterprise.sharepoint.com"

$Path = "C:\Temp\GroupsReport.csv"

$Cred =  Get-Credential

#Connect to SharePoint Online

Connect-SPOService -url$ServiceURL -Credential$Cred

#Generating Report

$GroupsData = @()

#get sharepoint online groups powershell

$SiteGroups =Get-SPOSiteGroup -Site$URL

ForEach($Group in $SiteGroups) {

    $GroupsData +=New-Object PSObject-Property @{

        'Group Name' =$Group.Title

        'Permissions' =$Group.Roles -join ","

        'Users' =  $Group.Users -join ","



#Export the data to CSV

$GroupsData |Export-Csv $Path-NoTypeInformation 

Output - Example:

Get SharePoint Online User Permission Report


How to Get a SharePoint Online Permissions Report with PowerShell or Netwrix Auditor

Prerequisites to execute the above script:

  • Need to install the SharePoint Online PowerShell module, the below command can be used to do so:

    Install-Module -Name Microsoft.Online.SharePoint.PowerShell

Refer to this MSDN Article: Get started with SharePoint Online Management Shell

How to pass credential in the Connect-SPOService?

We can use any of the below formats:

$username = "[email protected]"
$password = "password"
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)
Connect-SPOService -Url https://contoso-admin.sharepoint.com -Credential $cred


Connect-SPOService -Url https://contoso-admin.sharepoint.com -credential [email protected]


Connect-SPOService -Url https://contoso-admin.sharepoint.com

Source MSDN Article:


  • Thanks, when I run the Connect cmd I get: is not recognized as the name of a cmdlet, function, script file...
    – Dazza
    Apr 18, 2020 at 13:54
  • also in what format would I need to add the credentials in that line?
    – Dazza
    Apr 18, 2020 at 13:54
  • Answer updated - please check the updated answer - for the connection you can use the below code: $username = "[email protected]" $password = "password" $cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force) Connect-SPOService -Url contoso-admin.sharepoint.com -Credential $cred
    – SP 2022
    Apr 18, 2020 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.