-
Notifications
You must be signed in to change notification settings - Fork 386
Description
Reporting an Issue or Missing Feature
When calling the Get-PnPFolderInFolder
command with the -Recursive
flag from the root site collection of the SharePoint tenant, only the immediate child folders are returned. I believe this is due to the way in which the relativeUrl
variable is being calculated on GetFolderInFolder.cs:161 as for the root site, the value of CurrentWeb.ServerRelativeUrl
is "/"
. This results in all slashes from the target folder's ServerRelativeUrl
property being removed.
Expected behavior
The command should recursively iterate through all folders and subfolders.
Actual behavior
The command exclusively returns the immediate child folders. When enabling verbose logging, the command shows an incorrect path in the 'Processing folder' trace log. If given a library with the name 'ExampleLibrary' containing a folder named 'TestFolder' which in turn contains a subfolder named 'TestSubfolder01', the expected output would be 'Processing folder ExampleLibrary/TestFolder/TestSubfolder01', but instead 'Processing folder ExampleLibraryTestFolderTestSubfolder01' is displayed instead.
Steps to reproduce behavior
- If no suitable test list exists, create a new library in the root site collection of the tenant and add a hierarchy of folders. For this example there a folder called 'TestFolder' is created at the root of the library and another folder named 'TestSubfolder01' is created within this.
- Connect to the root site collection of a SharePoint tenant (e.g.
Connect-PnPOnline -Url https://contoso.sharepoint.com
) - Call
Get-PnPFolderInFolder
on the test library with the-Recursive
flag:
Get-PnPFolderInFolder -Identity 'ExampleLibrary' -Recursive -Verbose
- Observe that the script returns the 'TestFolder' folder but does not return 'TestSubfolder01' and that the path shown in the trace logs or verbose output is 'ExampleLibraryTestFolderTestSubfolder01'
What is the version of the Cmdlet module you are running?
3.1.0
Which operating system/environment are you running PnP PowerShell on?
- Windows
- Linux
- MacOS
- Azure Cloud Shell
- Azure Functions
- Other : please specify