Hi @Aase Nomad
You could use the following script to get the files in a folder:
#Config Variables
$SiteURL = "https://crescent.sharepoint.com/sites/Funds"
$ListName ="Funds"
$FolderServerRelativePath = "/sites/Funds/NeoFunds/EAEF IV*" #Any file under the given path
$ReportOutput = "C:\Temp\EAEFIV-Inventory.csv"
$Pagesize = 500
#Array to store results
$Results = @()
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -UseWebLogin
$List = Get-PnPList -Identity $ListName
$global:counter = 0;
$ListItems = Get-PnPListItem -List $ListName -PageSize $Pagesize -Fields Author, Editor, Created, File_x0020_Type -ScriptBlock `
{ Param($items) $global:counter += $items.Count; Write-Progress -PercentComplete ($global:Counter / ($List.ItemCount) * 100) -Activity `
"Getting Documents from Library '$($List.Title)'" -Status "Getting Documents data $global:Counter of $($List.ItemCount)";} | Where {$_.FieldValues.FileRef -like $FolderServerRelativePath}
$ItemCounter = 0
#Iterate through each item
Foreach ($Item in $ListItems)
{
$Results += New-Object PSObject -Property ([ordered]@{
Name = $Item["FileLeafRef"]
Type = $Item.FileSystemObjectType
FileType = $Item["File_x0020_Type"]
RelativeURL = $Item["FileRef"]
CreatedByEmail = $Item["Author"].Email
CreatedOn = $Item["Created"]
Modified = $Item["Modified"]
ModifiedByEmail = $Item["Editor"].Email
})
$ItemCounter++
Write-Progress -PercentComplete ($ItemCounter / ($ListItems.Count) * 100) -Activity "Exporting data from Documents $ItemCounter of $($ListItems.Count)" -Status "Exporting Data from Document '$($Item['FileLeafRef'])"
}
#Export the results to CSV
$Results | Export-Csv -Path $ReportOutput -NoTypeInformation
Write-host "Folder Inventory Exported to CSV Successfully!" -f Green
For more information, you could refer to:
https://www.sharepointdiary.com/2017/02/sharepoint-online-get-list-items-from-folder-using-powershell.html
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
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.