About Folder server relative URL

jennyKim 240 Reputation points
2023-06-19T06:47:17.05+00:00

I want to know where can i find FolderserverRelativeURL?

I searched but not found any suggestion

I want to grant permission to the folders in sharepoint using csv for this i tried with normal URL but gets error so to give permission on folder i need FolderserverRelativeURL i didnot find it does it mean i need to generate it through powershell or somethinh or i can garb it from sharepoint site?

Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

Accepted answer
  1. Emily Du-MSFT 51,836 Reputation points Microsoft External Staff
    2023-06-19T08:28:46.9466667+00:00

    Please run following PowerShell.

    #Parameters
    $SiteURL = "https://tenant.sharepoint.com/sites/emilytestcom"
    $ListName = "doc"
    $CSVPath = "C:\Folders.csv"
    $FoldersInventory = @()
     
    #Connect to Site
    Connect-PnPOnline -Url $SiteURL -Interactive
     
    #Get the List
    $List =  Get-PnPList -Identity $ListName
     
    #Get all Folders from List - with progress bar
    $global:counter = 0;
    $Folders = Get-PnPListItem -List $List -PageSize 500 -Fields FileLeafRef -ScriptBlock { Param($items) $global:counter += $items.Count; Write-Progress -PercentComplete ($global:Counter / ($List.ItemCount) * 100) -Activity "Getting Folders from List:" -Status "Processing Items $global:Counter to $($List.ItemCount)";}  | Where {$_.FileSystemObjectType -eq "Folder"}
       
    #Iterate through all folders in the list
    $Folders | ForEach-Object {
        #Collect Folder data
        $FoldersInventory += [PSCustomObject] @{
            FolderName = $_.FieldValues.FileLeafRef
            URL = $_.FieldValues.FileRef
        }  
    }
    $FoldersInventory
    $FoldersInventory | Export-Csv -Path $CSVPath -NoTypeInformation
    

    Result:

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.