Share via


SharePoint Online: Get any object with PowerShell (Part 1)

The examples below require a PowerShell module available on GitHub.

REST API

Microsoft provided us with great API endpoints that allows interacting with sites remotely. You can refer to the articles below to Get to know the SharePoint 2013 REST service better, or find out about Completing basic operations using SharePoint 2013 REST endpoints:

  1. https://msdn.microsoft.com/en-us/library/office/fp142380.aspx
  2. https://msdn.microsoft.com/en-us/library/office/jj164022.aspx

You can also find full endpoints reference here:

REST API reference

The cmdlet below leverages these possibilities to allow you to do what SharePoint Online Management Shell can't: retrieve SharePoint objects below site collection level, like lists, items, workflows, content types - you name it :)  

Before You Begin

  1. Download the module. 

  2. Import into your PowerShell using Import-Module cmdlet:

    import-module E:\technet\'Access Requests'\GetSPOObjects.psm1 -Verbose
    

  3. Get whatever you want :)

Sample Uses

Get all lists on a site

Get-SPOObject -Username t@t321.onmicrosoft.com -password $pass -Url  "https://t321.sharepoint.com/polski" -Object "web/lists"

Get a single list called "lista"

Get-SPOObject -Username t@t321.onmicrosoft.com -password $pass -Url  "https://t321.sharepoint.com/polski" -Object "web/lists/getbytitle('lista')"

Get all items from a list

Get-SPOObject -Username t@t321.onmicrosoft.com -password $pass -url https://t321.sharepoint.com
-object "web/lists/getbytitle('lista')/items"

Get all views from a list on a subsite

Get-SPOObject -Username t@t321.onmicrosoft.com -password $pass -Url "https://t321.sharepoint.com/polski" -Object "web/lists/getbytitle('Access Requests')/views"

Get all available content types' names from a subsite

Get-SPOObject -Username t@t321.onmicrosoft.com -password $pass -Url "https://t321.sharepoint.com/polski" -Object "web/availablecontenttypes"| select name

Get all site users

Get-SPOObject -Username t@t321.onmicrosoft.com -password $pass -Url https://t321.sharepoint.com/polski -Object "web/siteusers"

For more interesting and advanced scenarios check See Also.

If it's your first encounter with REST API and you are not sure what is possible, use this module. It is a more limited version, but you can TAB through all the suggestions for the -Object parameter.

Downloads

See Also

https://c.statcounter.com/11313207/0/e2a9c9ca/0/