

In Windows 7, under Programs, select Microsoft OneDrive. In Windows 10, select the OneDrive desktop app. Select the Start button, search for “OneDrive”, and then open it: I also use the Invoke-FslShrinkDisk script from GitHub to run each night to compact the VHDX files to reclaim the whitespace that is left behind.Important: To make sure you're getting the latest features and fixes, download and install the latest OneDrive app for free. I then have this set as a PowerShell logoff script in group policy. downloaded to the users OneDrive for Business cache), finally it uses the attrib.exe tool to set those files to "Online-only" (which removes the files from the OneDrive for Business cache).

This script gets the OneDrive for Business folder path of the logged on user and gathers all the file information, then it filters the results for just the files that have been set to "Locally Available" (e.g. Get-childitem $env:OneDriveCommercial -Force -File -Recurse | where Attributes -eq 'Archive, ReparsePoint' | foreach I haven't had the time to create a script that can set OneDrive files to "Online-only" after a set time of not being accessed, but I did manage to create a script that sets all OneDrive for Business files to "Online-only" mode on each logoff (Which avoids profiles becoming bloated by old/unused OneDrive cached files). I found through online guides that Windows 10 has a built-in tool called attrib.exe, which can be used to set OneDrive file states (Always available, Locally available and Online-only).

Here is what solution I ended up implementing.
