2

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

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:

https://contoso.sharepoint.com/_api/web/sitegroups

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 "username@contoso.onmicrosoft.com"
$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 Mar 13 '14 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 – Vadim Gremyachev Mar 13 '14 at 13:45
0

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

Example

$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, privacy policy and cookie policy

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