How to Download All Files from OneDrive for Business?

Requirement: Download all files and folders from OneDrive for Business site to the local disk.

How to download all the files from OneDrive?

OneDrive is a cloud-based storage solution from Microsoft that lets you store files online and share them with others. You can access your OneDrive files from any device, and there are several ways to download all the files from your account (or anyone else’s account when you have access!). In this article, we’ll show you how to quickly download OneDrive for Business files through the web browser interface. We’ll also show you how to use PowerShell to download all of your OneDrive for Business files. So let’s get started!

Here are the options available to download OneDrive for Business site:

  1. Select all files and folders and hit Download button in the toolbar
  2. Use the sync option and select “Always Keep on this device”
  3. Use the PowerShell script to download all files and Folders from OneDrive

Option 1: Download All Files and Folders from OneDrive for Business using Web Browser

Microsoft’s OneDrive for Business is a great way to store and share files. But what if you need to download all of the files from your OneDrive for Business account? Well, let me show you how to download all the files from your OneDrive for Business account.

Here is how to download all files from OneDrive for Business in just a few clicks:

  1. Login to your OneDrive site. URL shortcut: (or any other user’s OneDrive site – provided you have access to their OneDrive site already! If not, use How to Get Access to OneDrive for Business site of Other users?)
  2. Select all files and folders and hit “Download” button from the toolbar.powershell download onedrive for business files

This will download everything from the OneDrive site to a Zip file on your local PC.

Option 2: Download all files from OneDrive for business site using Sync Option

Let me show you how to download all your files from OneDrive so that you have a local copy on your computer with the Sync option. This way, you’ll always be able to access your files, even if there is an issue with OneDrive or the internet connection.

  1. Browse to the OneDrive site which you would like to download files from.
  2. Click on “Sync” button in the toolbar (Make sure you have OneDrive client installed in your local machine). This will start the sync process from OneDrive to your local disk. download all files from onedrive for business
  3. Open the File Explorer, Locate the Folder created from the sync operation under “YourDomain” node, Right-click on the folder and choose “Always keep on this device”. This starts downloading everything from the OneDrive instead of just establishing the sync all onedrive files locally

Option 3: PowerShell to Download OneDrive for Business

Do you ever find yourself needing to download files from OneDrive for Business, but don’t want to go through the web interface? Well, there’s a PowerShell way for that! Here is how to use the PowerShell script to easily download files from OneDrive for Business:

$OneDriveSiteURL = ""
$DownloadPath ="C:\Temp\OneDrive"

Try {
    #Connect to OneDrive site
    Connect-PnPOnline $OneDriveSiteURL -Interactive
    $Web = Get-PnPWeb

    #Get the "Documents" library where all OneDrive files are stored
    $List = Get-PnPList -Identity "Documents"
    #Get all Items from the Library - with progress bar
    $global:counter = 0
    $ListItems = Get-PnPListItem -List $List -PageSize 500 -Fields ID -ScriptBlock { Param($items) $global:counter += $items.Count; Write-Progress -PercentComplete `
                ($global:Counter / ($List.ItemCount) * 100) -Activity "Getting Items from OneDrive:" -Status "Processing Items $global:Counter to $($List.ItemCount)";} 
    Write-Progress -Activity "Completed Retrieving Files and Folders from OneDrive!" -Completed
    #Get all Subfolders of the library
    $SubFolders = $ListItems | Where {$_.FileSystemObjectType -eq "Folder" -and $_.FieldValues.FileLeafRef -ne "Forms"}
    $SubFolders | ForEach-Object {
        #Ensure All Folders in the Local Path
        $LocalFolder = $DownloadPath + ($_.FieldValues.FileRef.Substring($Web.ServerRelativeUrl.Length)) -replace "/","\"
        #Create Local Folder, if it doesn't exist
        If (!(Test-Path -Path $LocalFolder)) {
                New-Item -ItemType Directory -Path $LocalFolder | Out-Null
        Write-host -f Yellow "Ensured Folder '$LocalFolder'"
    #Get all Files from the folder
    $FilesColl =  $ListItems | Where {$_.FileSystemObjectType -eq "File"}
    #Iterate through each file and download
    $FilesColl | ForEach-Object {
        $FileDownloadPath = ($DownloadPath + ($_.FieldValues.FileRef.Substring($Web.ServerRelativeUrl.Length)) -replace "/","\").Replace($_.FieldValues.FileLeafRef,'')
        Get-PnPFile -ServerRelativeUrl $_.FieldValues.FileRef -Path $FileDownloadPath -FileName $_.FieldValues.FileLeafRef -AsFile -force
        Write-host -f Green "Downloaded File from '$($_.FieldValues.FileRef)'"
Catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red

This PowerShell script backup the OneDrive for Business to your local computer.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

10 thoughts on “How to Download All Files from OneDrive for Business?

  • I used this but keep running into issues for files that don’t have an extension. Is there a workaround for this? It stops each time I run into these errors.

  • Thanks so much for the great information! Will the PowerShell code in Option 3 work with my Personal Microsoft 365 subscription and OneDrive? Also, do it recreate all of the folders and sub folders just like it is currently setup in my OneDrive when it copies to a local HDD? Thanks in advance for your help and assistance in this regard.

  • Is there a way to automate the login and give it pre-define credentials?

  • The download function seems to fail if the zip file gets too big. I tried to download everything from a multi-gigabyte OneDrive account and the zip file stopped downloading after around 1.4GB.

    • Looks like that was a Chrome browser limit. Downloading in Edge has a 20GB limit for multiple folders, and apparently a 250GB limit if you get just one folder.

  • Hi,
    How to download all the users using the script in power chaning the variables these two variable.
    $OneDriveSiteURL = “”
    $DownloadPath =”C:\Temp\OneDrive”
    I have 600 users onedrive to download.

    Thanks for the help.

    • Hi Kiko,

      1. You can get all OneDrive for Business sites: $OneDriveSites = Get-SPOSite -Template “SPSPERS” -limit ALL -includepersonalsite $True
      2. Wrap the above code into a function and call the function for each site.

  • No option to keep folders “on this device”. Only works for files. MS is dumb..

  • April 12 > the download Link has been removed!!! ugg


Leave a Reply

Your email address will not be published. Required fields are marked *