SharePoint Online: Get any object with Powershell - sites and webs (Part 3)
The examples below require a Powershell module available here on Technet Gallery.
As discussed in Get any SharePoint Online object with Powershell, REST API endpoints allow us to interact with sites remotely. The examples below use these possibilities and together with a single cmdlet from a Powershell module pull useful data, troubleshoot your tenant and create reports in a way that is not possible with SharePoint Online Management Shell.
Sites
Get properties of the site collection
Get-SPOObject -Username t@t321.onmicrosoft.com -password $pass -Url 'https://t321.sharepoint.com' -Object "site"
Webs
Get subsites of a site
Get-SPOObject -Username t@t321.onmicrosoft.com -password $pass -Url 'https://t321.sharepoint.com' -Object "web/webs"
Get-SPOObject -Username t@t321.onmicrosoft.com -password $pass -Url 'https://t321.sharepoint.com' -Object "web/webs" | select url, webtemplate, created
Get groups user belongs to from entire site collection
Get-SPOObject -Username t@t321.onmicrosoft.com -password $pass -Url 'https://t321.sharepoint.com' -Object "web/siteusers/getbyid(11)/groups"
Get