0

Check OneDrive Usage Per User In Office 365

In this article I’m going to show you how to check OneDrive usage for users in Office 365. Since this task is really straight forward I’m going to share how to find it in the GUI as well as getting that information in Powershell.

Office 365 Requirements

Here is the small list of requirements needed:

  • Global Admin Rights – or –
  • SharePoint Administrator Rights
  • The user must be licensed for OneDrive (typically an E3 license is used)

 
Behind the scenes, OneDrive is essentially an extension of SharePoint so you will need SharePoint admin rights at a minimum to check the usage. In my case, I have global admin rights temporarily assigned.
Check OneDrive Usage Global Admin Rights

 

Check OneDrive Usage – GUI Method

If you want to check a single user it’s really quick and easy to check their usage in the GUI. Here’s how.

  • Navigate to the admin portal (https://admin.microsoft.com/)
  • Search for the user in the search bar
  • Click on the OneDrive tab to see their full stats

Check OneDrive Usage - Gui Method

Check OneDrive Usage – Powershell Method

I’ll admit, in this case the GUI method is a little bit easier. However, if you want to check users in bulk then Powershell is absolutely the best way. Let’s go over how to do that. You’ll need the Microsoft.Online.SharePoint.PowerShell Powershell Module installed.

  • Type: Import-Module Microsoft.Online.SharePoint.PowerShell
  • Type: $adminURL = ‘https://<YourTenantName>-admin.sharepoint.com‘ (e.g https://thesysadminchannel-admin.sharepoint.com)
  • Type: Connect-SPOService -Url $adminURL

Connect-SPOService Powershell
 

Now that we’re connected to SharePoint Online via Powershell, we can access those OneDrive cmdlets and properties.

  • Type: $URL = ‘https://<YourTenantName>-my.sharepoint.com/personal/<username>_<DomainName>_com’
  • Example would be: $URL = ‘https://thesysadminchannel-my.sharepoint.com/personal/pcontreras_thesysadminchannel_com’
  • Type: Get-SPOSite -Identity $URL | select Owner, StorageUsageCurrent, StorageQuota, Status

Check OneDrive Usage - Powershell Method

 

Check Multiple Users with Powershell Script

I wrote this quick script so you can pass on multiple usernames and have it output in a clean Powershell format we all know and love. It will also convert the default output from MB to GB.
 

Function Get-OneDriveUsage {
<#
.SYNOPSIS
    This will check OneDrive current usage and total limit.

.NOTES
    Name: Get-OneDriveUsage
    Author: theSysadminChannel
    Version: 1.0
    DateCreated: 2020-Sep-20

.LINK
    https://thesysadminchannel.com/check-onedrive-usage-for-users-in-office-365 -
#>

    [CmdletBinding()]
    param(
        [Parameter(
            Mandatory=$false,
            ValueFromPipeline=$true,
            ValueFromPipelineByPropertyName=$true,
            Position=0)]

        [string[]]  $SamAccountName = $env:USERNAME

    )

    BEGIN {
        $TenantName = 'thesysadminchannel'
        $DomainName = 'thesysadminchannel'
    }

    PROCESS {
        foreach ($User in $SamAccountName) {
            try {
                $URL = "https://$($TenantName)-my.sharepoint.com/personal/$($User)_$($DomainName)_com"
                $Stats = Get-SPOSite -Identity $URL | select Owner, StorageUsageCurrent, StorageQuota, Status
                [PSCustomObject]@{
                    Owner          = $Stats.Owner
                    CurrentUsageGB = "{0:F3}" -f ($Stats.StorageUsageCurrent / 1024) -as [decimal]
                    TotalStorageGB = "{0:F0}" -f ($Stats.StorageQuota / 1024) -as [int]
                    Status         = $Stats.Status
                }

            } catch {
                Write-Error $_.Exception.Message

            }
        }
    }

    END {}
}

Example: Get-OneDriveUsage -SamAccountName gabby, pcontreras

Get-OneDriveUsage -samaccountname
 

Hopefully you were able to check the Onedrive usage for the users in your environment. As I was writing this article I decided to write the Get-OneDriveUsage script as well because I didn’t like the fact that it output the numbers in MB and not GB.

Now using that script, you can check in bulk or on the fly as needed. Anyway, if you like to see more posts like this one, be sure to check our OneDrive Category. While you’re at it, don’t forget to stop by our Youtube Channel for awesome sysadmin video content.

Paul

Hi, my name is Paul and I am a Sysadmin who enjoys working on various technologies from Microsoft, VMWare, Cisco and many others. Join me as I document my trials and tribulations of the daily grind of System Administration.