Retrieving SharePoint lists in a web using Windows PowerShell

  • Start your windows PowerShell on your computer.
  • Right click and select Run as administrator option.
  • Paste the below script on the PowerShell window and click the enter button.
  • Check your SharePoint site Feature will activated successfully.
  1. $context = Connect-SPOSite https://gauti.sharepoint.com  
  2.   
  3. # The SharePoint web at the URL.  
  4. $web = $context.Web  
  5.   
  6. # Option 1: Let the API load what it wants to load  
  7. # Retrieve all lists from the server.  
  8.   
  9. $context.Load($web.Lists)  
  10.   
  11. # Option 2: Load specific properties  
  12. # Retrieve all lists from the server.  
  13. # For each list, retrieve Title and Id.  
  14.   
  15. Load-CSOMProperties -parentObject $web -collectionObject $web.Lists -propertyNames @("Id""Title") -parentPropertyName "Lists"  
  16.   
  17. # Execute query.  
  18.   
  19. $context.ExecuteQuery()  
Run the script with the required administrator privilege. To verify that, Check the output window. Thanks for reading my blog.
 
Hope you have enjoyed this..