how do u get a full url path for a given sharepint online folder

nellie 126 Reputation points
2021-03-14T11:38:59.147+00:00

Hi there have a criteria
there is a doc library on sharepint online which has many folders within this.
A user wants to put a title of a folder to find e.g 'Fox hides in the wood at 8:00 pm to catch a rabbit called f01xi' , how do I find the folder within the doc library.
I have tried pnp PowerShell using encode decode URL but no job, how can get I get full URL for a given folder title.

thanks

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,742 questions
{count} votes

Accepted answer
  1. Emily Du-MSFT 46,811 Reputation points Microsoft Vendor
    2021-03-19T10:06:30.247+00:00

    @nellie

    Try below PowerShell.

    #Variables  
    $SiteURL = "site URL"  
    $LibraryName = "library name"  
    $FolderName = "folder name"  
      
    Try {  
        #Get Credentials to connect  
        $Cred= Get-Credential  
        $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)  
      
        #Setup the context  
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)  
        $Ctx.Credentials = $Credentials  
        
        #Get the Library  
        $Library = $Ctx.web.Lists.GetByTitle($LibraryName)  
        $Folders = $Library.RootFolder.Folders  
        $Ctx.Load($Folders)  
        $Ctx.executeQuery()  
      
        #Get the Folder by Name  
        $Folder = $Folders | Where {$_.Name -eq $FolderName}  
        $Ctx.Load($Folder)  
        $Ctx.ExecuteQuery()   
          
        #Get Some Folder Properties  
        Write-host -f Green "Folder URL:"$Folder.ServerRelativeUrl  
    }  
    Catch {  
        write-host -f Red "Error Getting Folder!" $_.Exception.Message  
    }  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Emily Du-MSFT 46,811 Reputation points Microsoft Vendor
    2021-03-15T06:03:57.757+00:00

    @nellie

    Based on your description, I understand that yon want to find the path of the folder whose name is "Fox hides in the wood at 8:00 pm to catch a rabbit called f01xi".

    1.Use Search to find this folder.

    77590-1.png

    2.Select the file, click details panel, copy path.

    77616-2.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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.


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.