EASYENTRA

Knowledge Base

How to Export OneDrive with PowerShell

Use case: Use this procedure when you need to export one or more OneDrive sites to ZIP files in a consistent and repeatable way, for example for backup, archiving, migration, or compliance purposes. A ZIP file contains a compressed copy of the user’s OneDrive files and folders, making it easy to transfer or preserve the content outside Microsoft 365. Automating the export via PowerShell allows you to run exports in bulk, schedule the process, and integrate it with additional administrative or reporting tasks.

To export a user’s OneDrive to a ZIP file via PowerShell, use the built-in cmdlet Invoke-EEOneDriveToZip:

  • Open a PowerShell 7 command prompt using the same credentials you use to run EasyEntra.
  • Run the Invoke-EEOneDriveToZip cmdlet, specifying the user to export.

Invoke-EEOneDriveToZip
[-Identity] <string>
[-ModifiedAfter <datetime>]
[-ModifiedBefore <datetime>]
[-MaxFileSizeMB <Int64>]
[-SplitSizeMB <Int64>]
[-Tenant <string>]
[-Environment <string> {Global | USGov | USGovDod}

  • Optionally, use the available parameters to customize the export:
    • Filename to specify the output ZIP file name.
    • ModifiedAfter and -ModifiedBefore to export files modified within a specific date range.
    • MaxFileSizeMB to exclude files larger than the specified size.
    • SplitSizeMB to split the export into multiple ZIP files.
    • Tenant and -Environment to specify the target Microsoft 365 tenant and cloud environment.
  • Wait for the export to complete. The export duration depends on the size of the OneDrive and the number of files being exported.
  • Verify that the ZIP file was created successfully.

To schedule the process, ensure the scheduled task runs in the security context of a user account with a local user profile that holds the EasyEntra configuration and authentication. Ensure that the scheduled task is protected, allowing only authorized personnel to modify job settings.

Export a user’s OneDrive to a ZIP file using PowerShell.
ID:KB_124_OneDriveDelegation

Related Articles

OneDrive – How to Copy a OneDrive URL to the Clipboard

OneDrive – How to Configure External Sharing

OneDrive – How to Configure Storage Quota

OneDrive – How to Export OneDrive