Can I write a PowerShell Script to download all of my OneDrive online files and folders to HDD?

Roger Tregelles 0 Reputation points
2023-03-02T20:58:58.0266667+00:00

Hi Chris,

I’m brand new to using PowerShell. I need a fast and simple method (script) to download all of my online OneDrive files and folders to a local hard drive on a PC that does not have OneDrive installed. Doing so using the https://onedrive.live.com/ method is painfully slow and is limited to selecting only 100 GB of files at a time. I have 850+GB of files and folders that I need to download to a PC that is not running the OneDrive client. I found some PowerShell code at this website, but I’m not sure if this would do the job for me or not.

https://www.sharepointdiary.com/2021/09/how-to-download-all-files-from-onedrive-for-business.html

Thanks in advance for any and all help provided.

Roger

Microsoft 365 and Office OneDrive For business Windows
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,746 Reputation points
    2023-03-03T16:37:45.21+00:00
    
    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query.
    
    Sure, that is actually possible. You just have to use OneDrive API so the file can be accessed. I will show you an example on how to do this in Powershell:
    
    $files = Get-ChildItem -Path "\\OneDrive\Files"
    
    foreach ($file in $files) {
        $filePath = "\\OneDrive\Files\$file"
        $destinationPath = "C:\MyFiles\$file"
        DownloadFile($filePath, $destinationPath)
    }
    
    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.
    
    2 people found this answer helpful.
    0 comments No comments

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.