Hi @Roger Roger
I got all files and folders names in OneDrive My files library using the following PnP PowerShell Commands.
#Set Variables
$SiteURL= "https://contoso-my.sharepoint.com/personal/allenx_contoso_onmicrosoft_com"
$ListName="Documents"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
#Get All Files from the document library - In batches of 500
$ListItems = Get-PnPListItem -List $ListName -PageSize 500
#Loop through all documents
$DocumentsData=@()
ForEach($Item in $ListItems)
{
#Collect Documents Data
$DocumentsData += New-Object PSObject -Property @{
FileName = $Item.FieldValues['FileLeafRef']
FileURL = $Item.FieldValues['FileRef']
}
}
$DocumentsData | Export-Csv C:\temp\output.csv
Test on my end.
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.