Hey everyone! I've got a 9 TB OneDrive, and I'm trying to figure out which files are taking up the most space. For instance, I'm interested in files like .vmdk that are stored in OneDrive. I initially attempted to write a script to scan through all users' files, gathering file sizes and extensions, starting with the largest files. I used the Microsoft.Graph modules, but I hit a wall due to permission issues. After that, I created a new application in Azure AD and added necessary permissions, but I'm still struggling to log in through PowerShell. Is this the proper approach? I'm aiming to analyze the OneDrive data so that I can implement policies to reduce storage usage effectively. Thanks for any guidance!
3 Answers
A solid way to handle OneDrive and SharePoint Online is to use the `PnP.PowerShell` module, but note that the first-party enterprise app for this has been retired. Instead, create your own version through app registration. If your Entra account has Site Collection Administrator privileges for OneDrive, you can use interactive authentication with Graph. Also, consider the volume of files you're managing; if there are tons of large files, running PowerShell scripts on all of them may not be efficient. You might want to check the M365 Admin Center for reporting options, which could save you the trouble of manual checks.
Just a heads up, SharePoint does have a storage metrics page. It's accessible through Site Info settings. For OneDrive sites, you can manually access it by appending '/_layouts/15/storman.aspx' to your site URL. Additionally, using the `Get-PnPFolderStorageMetric` command should provide you with the data you need.
Just a note about using .vmdk files—storing those on OneDrive is usually not a great idea, as every small change to the file will lead to uploading the entire file again. This can really eat into your storage quickly and might cause issues with performance. Consider alternatives for those larger files!
Thanks for your insights! I'll definitely explore the interactive auth route and see what the Admin Center offers.