Fix OneDrive Dehydrate Command Leaving Some Files Local on Windows 11
🔍 WiseChecker

Fix OneDrive Dehydrate Command Leaving Some Files Local on Windows 11

You run the OneDrive dehydrate command expecting all synced files to become cloud-only placeholders, but some files remain marked as “Always keep on this device.” This happens when the command cannot override files with explicit local-pin settings or files in a blocked folder. OneDrive’s dehydrate operation respects per-file and per-folder attributes that you or an application set earlier. This article explains why the command fails for certain files and gives you a reliable method to force dehydration across your entire OneDrive folder on Windows 11.

Key Takeaways: Forcing Full OneDrive Dehydration on Windows 11

  • Right-click a file > “Free up space”: Manually dehydrates a single file that the command skipped.
  • OneDrive Settings > Sync and backup > Advanced settings > Files On-Demand: Toggle “Files On-Demand” off and on to reset all pin states.
  • PowerShell command Get-ChildItem -Recurse | Where-Object {$_.Attributes -match 'ReparsePoint'} | Set-ItemProperty -Name Attributes -Value ($_.Attributes -bxor [System.IO.FileAttributes]::ReparsePoint): Removes the reparse-point attribute on files that are stuck as local, allowing the dehydrate command to take effect.

ADVERTISEMENT

Why OneDrive Leaves Some Files Local After a Dehydrate Command

OneDrive Files On-Demand uses two attributes to track a file’s state: the “Always keep on this device” pin and the reparse-point attribute. When you right-click a file or folder and select “Always keep on this device,” OneDrive sets the reparse-point attribute to keep the full file content on the local drive. The dehydrate command — whether run from the OneDrive icon’s “Free up space” option or a PowerShell script — attempts to clear that attribute. However, the command does not force-remove the attribute on files that have an explicit user-set pin. It only changes files that are in the default “online-only” or “locally available” state.

Another reason is folder-level inheritance. If you set “Always keep on this device” on a parent folder, all files inside that folder inherit the local-pin attribute. The dehydrate command does not recurse into subfolders that have the local-pin flag set on the folder itself. Additionally, files that are currently open in an application or files with the “Read-only” attribute are skipped. Windows 11 also requires that the OneDrive process has full write permissions on the file’s directory. If a file is in a system-protected folder like “Desktop” or “Documents” and the user has not granted the appropriate permissions, the command will not touch it.

A third cause is a corrupted OneDrive cache. When the OneDrive sync engine’s local cache file (usually located in %LocalAppData%\Microsoft\OneDrive\settings\Business1\ClientPolicy or similar) becomes out of sync with the actual file attributes, the dehydrate command reads the cache instead of the file system. This results in the command skipping files that it believes are already dehydrated when they are not. Resetting the cache forces a fresh scan of all file states.

Steps to Force All OneDrive Files to Dehydrate on Windows 11

Follow these steps in order. Each step builds on the previous one to ensure no file is left local.

  1. Close all open files from your OneDrive folder
    Any file that is currently open in an application will be skipped by the dehydrate command. Save and close all documents, images, and other files. Also close any applications that might have file handles open, such as Microsoft Office, Adobe Reader, or a code editor.
  2. Remove the “Always keep on this device” attribute from all files using File Explorer
    Open File Explorer and navigate to your OneDrive folder. Press Ctrl+A to select all items. Right-click any selected file and choose “Free up space.” This command removes the local-pin attribute from every selected file that is not currently open or locked. If any file remains local after this step, proceed to the next step.
  3. Remove the “Always keep on this device” attribute from folders
    Right-click each subfolder that still shows the “Always keep on this device” icon — a solid green checkmark on the folder icon. Select “Free up space.” This clears the folder-level pin so that all files inside it can be dehydrated.
  4. Run the OneDrive “Free up space” command from the system tray
    Click the OneDrive cloud icon in the notification area of the taskbar. Click the gear icon and select “Settings.” Go to the “Sync and backup” tab and click “Advanced settings.” Under “Files On-Demand,” click “Free up disk space.” This command forces OneDrive to dehydrate all files that are not explicitly pinned. It may take several minutes for a large folder.
  5. Reset the OneDrive cache if files still remain local
    Press Windows key + R, type %LocalAppData%\Microsoft\OneDrive\ and press Enter. Locate the folder named “settings” and delete its contents. Then right-click the OneDrive icon in the system tray and choose “Exit.” Restart OneDrive from the Start menu. Sign in again. OneDrive will rebuild its cache and re-evaluate all file states. After the sync completes, repeat step 4.
  6. Use PowerShell to remove the reparse-point attribute on stubborn files
    Open PowerShell as Administrator. Run the following command to list all files in your OneDrive folder that have the reparse-point attribute set:
    Get-ChildItem "C:\Users\YourUsername\OneDrive" -Recurse -File | Where-Object {$_.Attributes -match 'ReparsePoint'} | Select-Object FullName
    If the output shows files that you expected to be dehydrated, remove the reparse-point attribute by running:
    Get-ChildItem "C:\Users\YourUsername\OneDrive" -Recurse -File | Where-Object {$_.Attributes -match 'ReparsePoint'} | Set-ItemProperty -Name Attributes -Value ($_.Attributes -bxor [System.IO.FileAttributes]::ReparsePoint)
    Replace the path with your actual OneDrive folder path. After running the command, restart OneDrive from the system tray.
  7. Toggle Files On-Demand off and on
    In OneDrive Settings > Sync and backup > Advanced settings, under “Files On-Demand,” toggle the switch to “Off.” Click “Apply” and wait for OneDrive to download all files locally. Then toggle it back to “On.” This resets the entire pin state for all files and folders. After the sync completes, run the “Free up space” command again.

ADVERTISEMENT

If OneDrive Still Leaves Files Local After the Main Fix

Files in system folders like Desktop or Documents remain local

Windows 11 protects the Desktop, Documents, and Pictures folders by default. OneDrive cannot dehydrate a file that is inside a folder that is also synced by the Windows system backup feature. To fix this, go to Settings > Accounts > Windows backup and turn off the “Remember my apps” and “Back up my folders” options. Then restart OneDrive. After the restart, the files in those folders will be eligible for dehydration.

OneDrive reports “This file is in use” even though the application is closed

A background process may hold a file handle. Open Task Manager with Ctrl+Shift+Escape. Look for processes under the “Processes” tab that might be using the file, such as Windows Search Indexer, antivirus software, or a cloud backup client. End those processes temporarily. Then run the “Free up space” command. If the file is still locked, restart Windows 11 and run the command immediately after the desktop appears, before launching any other application.

OneDrive shows a “Sync pending” icon and never dehydrates

A large number of files or a slow internet connection can cause OneDrive to pause the dehydrate operation. Open OneDrive Settings > Sync and backup > Manage backup and check if any folder is still syncing. Wait for the sync to complete. If the sync is stuck, pause and resume OneDrive sync from the system tray menu. Then run the “Free up space” command again.

Item Free up space (Manual) PowerShell attribute removal
Scope Selected files or entire OneDrive folder All files with reparse-point attribute in a path
Requires admin rights No Yes
Respects folder-level pins No — it skips pinned folders Yes — it removes the attribute regardless of folder pin
Risk of data loss None Low — only removes the local-pin attribute, not the file
Best for Quick cleanup of a few files Bulk dehydration of hundreds of stuck files

Now you can force any stubborn file to become cloud-only on Windows 11. The most reliable method is toggling Files On-Demand off and on, which resets all pin states. For future control, use the OneDrive “Free up space” command weekly from the system tray to prevent files from accumulating local copies. If you manage multiple workstations, deploy a Group Policy setting that disables the “Always keep on this device” option for users to avoid the problem entirely.

ADVERTISEMENT