Get All Document Libraries in SharePoint Online using PnP PowerShell
Requirement: Get all document libraries in SharePoint Online using PowerShell PnP.
PnP PowerShell to Get All Document Libraries in SharePoint Online
Would you like to get a list of all document libraries on your SharePoint Online site? PowerShell makes it easy! I’ll show you how to use PowerShell to get a list of all document libraries on your site in this post.
To get the list of libraries, you first need to connect to SharePoint Online using PowerShell. Once you’re connected, you can run the Get-PnPList cmdlet to get a list of all the lists and libraries in the sites and filter the document libraries from them. Document libraries can be filtered from the Lists collection by either base template or base type properties. Here is how:
#Set Variables
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Get all document libraries - Exclude Hidden Libraries
$DocumentLibraries = Get-PnPList | Where-Object {$_.BaseTemplate -eq 101 -and $_.Hidden -eq $false} #Or $_.BaseType -eq "DocumentLibrary"
#Get Document Libraries Name, Default URL and Number of Items
$DocumentLibraries | Select Title, DefaultViewURL, ItemCount
This PowerShell script gets all document libraries from the given site URL, along with the library URL and a number of items in each library. This can be useful if you need to generate a report or perform some other analysis on the libraries, or even iterate through all document libraries in a site.
Here is another script to get all document libraries on the SharePoint Online site using CSOM PowerShell: SharePoint Online: PowerShell to List All Document Libraries
Really great information here.
I have a Document Library that contains many pdf’s titled 12345.pdf. Each pdf has a corresponding xml file that share the same 12345 prefix (12345.xml)
Is there a way for me to iterate through the Document library, grab the matching xml file, and import the xml values into the corresponding meta data properties of each pdf in the Document Library?
Any suggestions or hints you can point me towards is very much appreciated.
Thank you
Yes! This is fairly possible. You can obtain metadata values from the XML file and update the file’s properties. Here are some references:
https://www.sharepointdiary.com/xml
SharePoint Online: How to Update Document Metadata using PowerShell?