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:

  • Login to your OneDrive site. URL shortcut: https://YourDomain-My.sharepoint.com/ (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?)
  • 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.

  • Browse to the OneDrive site which you would like to download files from.
  • 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
  • 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 link.download 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:

#Parameters
$OneDriveSiteURL = "https://crescent-my.sharepoint.com/personal/salaudeen_crescent_com"
$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 is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

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

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

    Reply

Leave a Reply