guide · static export
PC · onedrive

Turn On OneDrive Files On-Demand and Free Local Space

Every synced file does not have to live on the disk. Files On-Demand keeps the placeholders and downloads content when you open it, which frees gigabytes without breaking anything.

by@guidox updated:10/31/26 time:15 min level:Beginner tested on:Windows 11 24H2 works on:Windows 10, Windows 11 tools:OneDrive, Command Prompt
TL;DR

Enable **Files On-Demand** in OneDrive settings, dehydrate a folder with **attrib +U -P /s /d**, and pin the folders you need offline with **Always keep on this device**.

Before you start

Requirements

  • OneDrive signed in
  • NTFS on the system drive
  • 15 minutes
Step by step

Instructions

01

See what actually occupies the disk

The folder looks the same in Explorer either way. The attribute tells you whether a file has local content: **Offline** means the data is on disk.

$root = "$env:USERPROFILE\OneDrive"
Get-ChildItem $root -Recurse -File -ErrorAction SilentlyContinue |
  Measure-Object Length -Sum | Select-Object Count,@{n='GB';e={[math]::Round($_.Sum/1GB,1)}}
(Get-Item "$root\Documents").Attributes
02

Enable Files On-Demand

The switch lives in the OneDrive settings under **Save space and download files as you use them**. Without it, the Free up space command removes the local copy permanently instead of leaving a placeholder.

:: OneDrive tray icon > Settings > Sync and backup > Advanced settings
:: or open the settings dialog directly:
%LOCALAPPDATA%\Microsoft\OneDrive\OneDrive.exe /settings
⚠ warningFiles On-Demand needs NTFS. On exFAT or on a network share the option stays hidden, and Free up space deletes the file from the disk.
03

Free space for one folder

Right-click gives the documented route and shows the state icon afterwards. Use it once to see what a dehydrated folder looks like before you script it.

:: Explorer > right-click the folder > Free up space
Get-ChildItem "$env:USERPROFILE\OneDrive\Archive" -File |
  Select-Object -First 3 Name,Attributes
04

Free space in bulk

The **+U** attribute marks files as online-only, **-P** clears the pinned flag. Run it in the folder you want to shrink, not at the OneDrive root, or everything including your working set goes remote.

cd "$env:USERPROFILE\OneDrive\Archive"
attrib +U -P /s /d
Get-PSDrive C | Select-Object Used,Free
tipDehydrated files still count against your OneDrive quota. This saves local disk, not cloud storage.
05

Pin the folders you need offline

Anything you open on a plane or during a meeting must be marked **Always keep on this device**. A pinned folder survives the next bulk dehydrate as long as you do not run attrib on it.

cd "$env:USERPROFILE\OneDrive\Work"
attrib -U +P /s /d
(Get-Item .\Project.docx).Attributes
06

Verify space and sync health

Check the free space and confirm that OneDrive is not stuck processing the change. A paused sync plus dehydrated files is the combination that loses work.

Get-Volume C | Select-Object DriveLetter,@{n='FreeGB';e={[math]::Round($_.SizeRemaining/1GB,1)}}
Get-Process OneDrive | Select-Object Id,CPU,StartTime
Troubleshooting

Common issues

Free up space is missing from the context menu

Files On-Demand is off or OneDrive is not running. Restart OneDrive and check the setting again; on exFAT the feature is unavailable.

Files stayed on disk after the command

They are pinned, open in an application, or inside an excluded folder such as an Outlook cache. Close the app and repeat with -P.

An online-only file will not open

The machine is offline or the account needs re-authentication. The placeholder has no content until OneDrive can download it.

Space did not change

Read the numbers again after the sync finishes; the counter lags. If they still match, the files were never local to begin with.

FAQ

Frequently asked

Is my data still there after dehydrating?

Yes. The file exists as a placeholder and downloads on first access, as long as the account stays signed in.

Can I lose data this way?

Not through dehydrating. Delete a placeholder and the file goes to the OneDrive recycle bin like any other deletion.

How to undo this

Turn Files On-Demand off in OneDrive settings and choose Download all files, or pin the specific folders with attrib -U +P /s /d. Local space usage returns to what it was.

Changelog · 1 entry
  1. 2026-10-31
    First version
Interactive version: checklist, feedback, related guides →

Free · no account needed · tracks your progress