Search code examples
powershellwmioffline-caching

Powershell Offline Files Space (Win32_OfflineFilesDiskSpaceLimit)


I'm trying to write a PowerShell script to get some basic information about offline files on Windows 10 computers, including the cache size limit and amount of space in use. It appears that both of these values are stored properties of the WMI class Win32_OfflineFilesDiskSpaceLimit. As seen here, the properties of this class are:

  • AutoCacheSizeInMB (appears to be the space in use)
  • TotalSizeInMB (appears to be the space allotted)

However, when I attempt to run the following, nothing is returned:

Get-WmiObject -Class Win32_OfflineFilesDiskSpaceLimit

I have confirmed that Win32_OfflineFilesCache says Active and Enabled are both true.

If there is a better way to gather this information, I am open to suggestions, but I'm still curious why these properties don't seem to exist.

Note: I'm currently using Measure-Object on the Offline Files location to get the amount of space in use, but I can't get the limit this way.


Solution

  • For anyone looking at this in the future, it appears the solution is that an instance of this class exists as a member of the WMI class Win32_OfflineFilesMachineConfiguration (and perhaps also Win32_OfflineFilesUserConfiguration - not sure on that one).

    gwmi win32_offlinefilesmachineconfiguration | select -expand diskspacelimitparams
    

    The values are not what I had expected (the AutoCacheSizeInMB property is empty, and the TotalSizeInMB is significantly larger than the result of gci C:\Windows\CSC -Recurse -Force | Measure Length -Sum), but I can tackle that issue separately.