Loading...

Getting OneDrive size and real size on disk using PowerShell

Reply A+ A-


In this post I will show you a way to get OneDrive size, and OneDrive real size on disk using PowerShell.


Context

When you use OneDrive, your files have two size properties:

- Full size

- Real size used on your disk


You can get both by doing a right-click on your OneDrive folder, as below:


Size: the full size of your OneDrive.

Size on disk: size that a file takes on your local drive.


When you go in your OneDrive folder there are some different behaviors:

- File with a blue cloud icon: located on the cloud and not on your drive

- File with a green check: located on OneDrive but downloaded once


The script

By default you can only get full size but not size real size on disk.

To get both information, size and size on disk we will use bit of .NET class and function GetCompressedFileSizeW.

We will use Pinvoke.NET to access to some classes: 

- System

- System.Runtime.InteropServices

- System.ComponentModel

- System.IO


Get the script

Click on the below GitHub picture to get the script:


How it works 

Run the script Get_OD_SizeOnDisk.ps1

See below an overview:

slider 6246869926838051835

Enregistrer un commentaire

Accueil item

Award

Sponsors

Learn KQL in one month

You want to support me ?

Mes articles en français

Books in French


Stats