Office 365: Get OneDrive for Business Usage Report using PowerShell

Requirement: Get OneDrive for business usage report using PowerShell

How to Check the OneDrive for Business Usage for a User in Office 365?
OneDrive for Business is a Microsoft's cloud-based storage solution that lets you store and work on files that are personal to you. Its similar to any other document library in SharePoint with full control granted to you, so that you can add, update, and delete files or folders in your OneDrive. To get the storage usage on OneDrive for business for a specific user,
  • Login to Office 365 Admin Centre, Search and find the user.
  • From user settings page, expand the OneDrive for business settings menu and under Quota You'll see the Storage used value!
    onedrive for business usage powershell


PowerShell to Check OneDrive for Business Usage
Here is the PowerShell to check OneDrive for business usage.
#Variables
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$OneDriveURL = "https://crescent-my.sharepoint.com/personal/salaudeen_crescent_com"
 
#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL # -credential (Get-Credential)

#Get All Properties of the OneDrive Site
Get-SPOSite $OneDriveURL | Select -Property *

To get OneDrive for business site size using PowerShell, you can use:
Get-SPOSite $OneDriveURL | Select @{Name="Storage Used";Expression={$_.StorageUsageCurrent}}

How about getting OneDrive for Business storage space for all sites? Well, using PowerShell we can create a quick report to check how much storage does OneDrive for business sites have.
#Variable for SharePoint Online Admin Center URL
$AdminSiteURL="https://crescent-admin.sharepoint.com"
 
#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -credential (Get-Credential)

#Get All OneDrive Sites
Get-SPOSite -IncludePersonalSite $true -Limit all -Filter "Url -like '-my.sharepoint.com/personal/'"
This PowerShell script pulls all OneDrive for Business sites.
onedrive for business usage report using powershell

Export OneDrive for Business sites storage size report to CSV
Let's pull Onedrive for business usage using powershell and export the result to CSV file.
#Variable for SharePoint Online Admin Center URL
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$CSVFile = "C:\Temp\OneDrives.csv"
 
#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -credential (Get-Credential)

#Get All OneDrive Sites usage details and export to CSV
Get-SPOSite -IncludePersonalSite $true -Limit all -Filter "Url -like '-my.sharepoint.com/personal/'" | Select URL, Owner, StorageQuota, StorageUsageCurrent, LastContentModifiedDate | Export-Csv -Path $CSVFile -NoTypeInformation
This PowerShell script retrieves URL, Owner, Storage Quota allocated, Storage Used and Last Updated Date property values of all OneDrive for Business sites and generates report as below:

powershell check onedrive for business usage

This generates a report listing all OneDrive for Business sites in the tenant with the storage allocated and used for each site. Here is another post to get OneDrive storage quota using PowerShell: Get OneDrive for Business Size using PowerShell

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.