Powershell Calling SharePoint Webservice

Powershell can be used for many things. In this case i would like to fetch data from SharePoint lists.

Powershell can work with data from

  • a Database
  • an Active Directory
  • SharePoint via API
  • Excel
  • XML
  • etc.

In my case i just use Powershell to get data from a webservice like the SharePoint webservice /_vti_bin/lists.asmx

This example was the basic for me to get data from a MS Dynamics CRM system. But to keep it simple i will stay in SharePoint

At first i define a variable for the webservice URL and then i create the proxy. With the proxy i can access the methods of the webservice.

[sourcecode language=”Csharp”]

#URL for the Webservice
$URI = “http://server/sites/sitecollection/_vti_bin/lists.asmx?WSDL”
#Call a proxy
$proxy = New-WebServiceProxy -Uri $URI -Class ILSWebservice -Namespace ILS -UseDefaultCredential
#Get the list
$list = $proxy.GetList(‘Documents’)
#Display the list title
$list.Title

[/sourcecode]

The Namespace and class doesn’t matter at this time. Just name it like you want

How cool is that?

So in the next steps, you can use these webservices to update SharePoint Items or do anything else. You don’t need to run the Powershell on the SharePoint Server itself, so your possibilities are huge.

Happy Powershelling 🙂

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

About Karsten Schneider 312 Articles
Consultant for Microsoft 365 Applications with a strong focus in Teams, SharePoint Online, OneDrive for Business as well as PowerPlatform with PowerApps, Flow and PowerBI. I provide Workshops for Governance & Security in Office 365 and Development of Solutions in the area of Collaboration and Teamwork based on Microsoft 365 and Azure Cloud Solutions. In his free time he tries to collect tipps and worthy experience in this blog.

Be the first to comment

Leave a Reply

Your email address will not be published.


*