Wed. Jun 8th, 2022
Function Delete-ALL-Libraries-Target([String]$SiteURL,$Credentials)
{
    Try{
        #Connect to PnP Online
        Connect-PnPOnline -Url $SiteURL -Credentials $Credentials
        #Get the Root Web
        $Web = Get-PnPWeb
        $Lists= Get-PnPList -Web $Web

        foreach ($List in $Lists)
        {

            if ($Global:listExclusions.Contains($List.Title) -eq $false)
            {

            write-host Found $List.Title
            if($List.count -eq 1)
            {
                Remove-PnPList -Identity $List.title -Recycle -Force
                write-host Removed $List.Title
            }
        }
       }

    }
    Catch{
      write-host -f Red "Error deleting library!" $_.Exception.Message
    }

}

This website uses cookies. By continuing to use this site, you accept our use of cookies.