I have this PnP Power-shell to loop through all sites >> then all libraries >> then list all the main folders inside the libraries.
$AdminUrl = "https://****-admin.sharepoint.com/"
Connect-PnPOnline -Url $AdminUrl -Interactive
#sharepoint online get all site collections PowerShell
$SiteColl = Get-PnPTenantSite
$csvOutput = @()
#sharepoint online PowerShell iterate through all site collections
ForEach($Site in $SiteColl)
{
Connect-PnPOnline -Url $Site.Url -Interactive
$Webs = Get-PnPSubWeb -Recurse -IncludeRootWeb
#Get All document libraries
ForEach($Web in $Webs)
{
$DocumentLibraries = Get-PnPList -Web $Web | Where-Object {$_.BaseType -eq "DocumentLibrary" -and $_.Title -ne "Site Assets" -and $_.Hidden -eq $false}
#Iterate through each document library
ForEach($Library in $DocumentLibraries)
{
#Get all Subfolders of a folder - recursively
$SubFolders = Get-PnPFolderItem -FolderSiteRelativeUrl $Library.RootFolder.ServerRelativeUrl -ItemType Folder #-Recursive
ForEach($folder in $SubFolders)
{
Write-Host $Site.Title " --> " $Library.RootFolder.ServerRelativeUrl " --> " $folder.Name " --> " $folder.ServerRelativeUrl
$csvOutput += [PsCustomObject]@{SiteTitle = $Site.Title; LibraryTitle = $Library.RootFolder.ServerRelativeUrl; Folder = $folder.Name; FolderPath = $folder.ServerRelativeUrl}
}
}
}
}
$csvOutput | Export-Csv -NoTypeInformation -Path "D:\export123.csv"
The script is working fine, but i am getting this warning:-
WARNING: Parameter 'Web' is obsolete. The -Web parameter will be removed in a future release. Use Connect-PnPOnline -Url [subweburl] instead to connect to a subweb.
so what i need to modify to make my code future proof?
Thanks