I need to export my site collection's groups from sharepoint online. I have create the following script to get all the info but I cannot retrieve the group's Id. I am talking about this ID https://xxxxxx.sharepoint.com/_layouts/userdisp.aspx?ID=28

Get-SPOSiteGroup -Site https://xxxxxx.sharepoint.com | select * | Format-Table -Wrap -AutoSize | Out-File C:\Scripts\ExportedGroups.txt -Force -Width 4096

The script will return info on the following:

  • LoginName
  • Title
  • OwnerLoginName
  • OwnerTitle
  • Users Roles

but no ID. Is it possible to retrieve that as well? Maybe is there a sharepoint list with all the users/groups I could export instead?


2 Answers 2


Cmdlet Get-SPOSiteGroup returns the collection of SPOSiteGroup objects but Group ID is not exposed in this object.

Invoking SharePoint Online REST requests from PowerShell

The following REST request could be used to return site collection groups:


You could invoke REST requests in SharePoint Online using Invoke-RestSPO.ps1 PS Script . Please refer this post for a more details.

Example: print site groups information:

$results = .\Invoke-RestSPO.ps1 -Url "https://contoso.sharepoint.com/_api/web/sitegroups" -UserName "[email protected]"
$results | select Title, id | Format-Table -Wrap -AutoSize
  • 1
    This is great. Wish I could award you something more than just one tick. This thing will come in handy in so many ways!
    – Perisdr
    Commented Mar 13, 2014 at 12:36
  • Thanks! :) Indeed, it makes available the whole SharePoint REST API for usage from PS. In my opinion SharePoint Online cmdlets covers very limited functionality Commented Mar 13, 2014 at 13:45

Alternatively you could use Get-SPOGroups

Here's an example

$ctx = Get-SPOContext url username password
Get-SPOGroups -Web $ctx.Web

This will give you a list of groups and ids in the rootweb. If you need users there is also Get-SPOWebUsers


$ctx = Get-SPOContext url username password
Get-SPOWebUsers -Web $ctx.Web

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.