Hi All<\/p>\n
I want to export the contents of a user’s OneDrive to a CSV file. When I use the below syntax, I get the output, but I have to specify the list name. Is it possible to export all the contents to a CSV file without specifying the list name? Please guide me.<\/p>\n
#Set Variables\n $SiteURL= \"https://contoso-my.sharepoint.com/personal/glenn_max_contoso_com\"\n $ListName=\"Documents\"\n #Connect to PnP Online\n Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)\n #Get All Files from the document library - In batches of 500\n $ListItems = Get-PnPListItem -List $ListName -PageSize 500\n #Loop through all documents\n $DocumentsData=@()\n ForEach($Item in $ListItems)\n {\n #Collect Documents Data\n $DocumentsData += New-Object PSObject -Property @{\n FileName = $Item.FieldValues['FileLeafRef']\n FileURL = $Item.FieldValues['FileRef']\n }\n }\n $DocumentsData | Export-Csv C:\\temp\\output.csv\n<\/code><\/pre>","upvoteCount":3,"answerCount":1,"datePublished":"2025-06-26T02:51:25.008Z","author":{"@type":"Person","name":"Glenn-Maxwell","url":"https://community.spiceworks.com/u/Glenn-Maxwell"},"suggestedAnswer":[{"@type":"Answer","text":"
Advertisement
Hi All<\/p>\n
I want to export the contents of a user’s OneDrive to a CSV file. When I use the below syntax, I get the output, but I have to specify the list name. Is it possible to export all the contents to a CSV file without specifying the list name? Please guide me.<\/p>\n
#Set Variables\n $SiteURL= \"https://contoso-my.sharepoint.com/personal/glenn_max_contoso_com\"\n $ListName=\"Documents\"\n #Connect to PnP Online\n Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)\n #Get All Files from the document library - In batches of 500\n $ListItems = Get-PnPListItem -List $ListName -PageSize 500\n #Loop through all documents\n $DocumentsData=@()\n ForEach($Item in $ListItems)\n {\n #Collect Documents Data\n $DocumentsData += New-Object PSObject -Property @{\n FileName = $Item.FieldValues['FileLeafRef']\n FileURL = $Item.FieldValues['FileRef']\n }\n }\n $DocumentsData | Export-Csv C:\\temp\\output.csv\n<\/code><\/pre>","upvoteCount":3,"datePublished":"2025-06-26T02:51:25.683Z","url":"https://community.spiceworks.com/t/export-the-listitems/1218533/1","author":{"@type":"Person","name":"Glenn-Maxwell","url":"https://community.spiceworks.com/u/Glenn-Maxwell"}}]}}