7

I'm using PNP Powershell and am still fairly new to Powershell and scripts. I need to get the count of all document libraries and workflows in our SharePoint environment. I am using SharePoint 2013 Online off-prem.

I've been looking through some PNP Powershell commands and can't grasp any of that would help me achieve this.

2

This should get you most of the way there, with a few issues.

It only counts 2013 platform workflows.

I haven't found a way to limit the library count to only show document libraries, it counts all lists. If you can find that, the rest of the structure should work fine, you just need to point it at each site collection in turn.

$siteurl = "https://tenancy.sharepoint.com/sites/scname"
$tenancy = "https://tenancy.sharepoint.com"

$credentials = Get-Credential

Connect-PnPOnline -Url $siteurl -Credentials $credentials

$sites = Get-PnPSubWebs

Disconnect-PnPOnline

$WflowDefnCount = 0
$LibraryCount = 0

foreach ($site in $sites){
    Connect-PnPOnline -Url "$tenancy$($site.ServerRelativeURL)" -Credentials $credentials
    $Wflows = Get-PnPWorkflowDefinition
    $WflowDefnCount =+ $Wflows.count
    $Lists = get-pnplist
    $LibraryCount =+ $Lists.count

}
Write-Host "Workflow count = $WflowDefnCount"
Write-Host "List count = $LibraryCount"
  • awesome, thank you, i will be trying this out later today! – Mark Apolinar Jun 16 '17 at 17:40
  • 1
    Thanks again man, I did find a way to differentiate Doc libraries: get-pnplist | Where-Object{$_.BaseTemplate -eq 101} | Measure-Object | select count – Mark Apolinar Jun 29 '17 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.