PnP PowerShell to get file URL in SharePoint Online specific folder:
#Set Variables
$SiteURL= "https://tenant.sharepoint.com/sites/Team1"
$ListName="Documents"
$prefix="https://tenant.sharepoint.com"
#Connect to PNP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
#Get All Items from the specific folder - In batches of 500
$ListItems = Get-PnPListItem -List $ListName -FolderServerRelativeUrl "/sites/Team1/Shared%20Documents/Folder1027" -PageSize 500
#Loop through List Items and Get File URL
$Results=@()
ForEach($Item in $ListItems)
{
$Results += New-Object PSObject -Property @{
FileName = $Item.FieldValues['FileLeafRef']
FileURL = $prefix + $Item.FieldValues['FileRef']
}
}
$Results
Result for your reference:
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.