Working with the SharePoint Online REST service via PowerShell

Since SharePoint 2013 introduces a Representational State Transfer (REST) service that is comparable to the existing SharePoint client object models, it opens up a huge capabilities, in particular for administering and automating SharePoint Online when used with PowerShell.

My first idea was to utilize  Invoke-RestMethod cmdlet, which was introduced in Windows PowerShell 3.0.  Invoke-RestMethod cmdlet contains Credential parameter which could  accept basic, digest, NTLM, and Kerberos authentication.

SharePoint Client Component SDK comes with  a SharePointOnlineCredentials class  which represents an object that provides credentials to access SharePoint Online resources. But unfortunately SharePoint Online credentials could not be passed in Invoke-RestMethod cmdlet, since claims based authentication is not supported by this cmdlet.

Below is demonstrated a simplified PowerShell script  that to some extent mimics Invoke-RestMethod cmdlet. This script is intended for sending HTTPS request to a SharePoint Online REST service:



7 thoughts on “Working with the SharePoint Online REST service via PowerShell

  1. Pingback: Consuming the SharePoint 2013 REST API from PowerShell | Yet Another SharePoint Blog

  2. Pingback: Invoke-SPORestMethod: Using the SharePoint Online REST API with PowerShell « SharePoint Automation

  3. Pingback: Consuming the SharePoint Online REST API from PowerShell: Part 2 | YASP Blog

  4. Hi Vadim, I tried to access “My site” but the script fails with

    Exception lors de l’appel de « GetResponse » avec « 0 » argument(s) : « The request was aborted: The request was canceled. »
    Au caractère C:\temp\sharepoint.ps1:23 : 1
    + $response = $request.GetResponse()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

    I have to pass trough a proxy in my office, I tried

    but it also failed.
    What can I try next?
    Thank you

Leave a Reply to Igor Cotruta (@igocrete) Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.