Getting Onedrive usage of the members of specific group via powershell

Hi I hope I can find answer here. I’m having a hard time getting the exact command where I can get the onedrive usage of the members of my distribution list. I was able to get the report for all the users but what I need is just the member of this specific distribution list and it has 600 members. I would really appreciate your input on this. Thanks in advance!

Welcome to the forum. :wave:t4:

Why don’t you show the code you used? We might be able to tweak it the way you want. :wink:

Do you know how to get …

… ? :wink:

Hi I’m sorry I’m not really good with scripting. I was able to run bellow command from other site but I need the one that will only get the info of the distribution list members.

8 #Variable for SharePoint Online Admin Center URL

$AdminSiteURL = ""

#Connect to SharePoint Online Admin Center

Connect-SPOService -Url $AdminSiteURL -credential ( Get-Credential )

#Get All OneDrive Sites

Get-SPOSite -IncludePersonalSite

#Read more:

I was able to get the members of the distribution list through Exhange online powershell, however I don’t know how to connect it to Onedrive powershell to get their usage report. Please help!

Hmmm … your code is actually not that helpful since I don’t have access to a tenant with a SharePoint Online service and I don’t know how the output looks like.

Anyway … I can show how you filter one list with another list where at least one property of both lists has to be the same on both sides.

Lets assume your query of exchange online provided the following list:

$ExchangeOnlineDLMemberList = @'
'@ |

The output of $ExchangeOnlineDLMemberList would look like this:

UserName ID
-------- --
John     1010
George   1011
Paul     1012
Ringo    1013

Now you query your SharePoint Online … we simulate that with this snippet …

$SPOSiteList = @'
'@ |

And the output of $SPOSiteList looks like this:

SPOSite    UserID
-------    ------
SPOJohn    1010
SPOMick    1110
SPOGeorge  1011
SPOKeith   1111
SPOPaul    1012
SPORon     1112
SPORingo   1013
SPOCharlie 1113

Now you have a few option to filter the $SPOSiteList. You could use Where-Object like this:

$SPOSiteList |
    Where-Object -Property UserID -In -Value $ExchangeOnlineDLMemberList.ID

Or you use Compare-Object. But for that the properties you want to compare need the same names. That’s we we need to tweak the $ExchangeOnlineDLMemberList to have a property UserID - just like the $SPOSiteList .

$EOCompareList = 
    $ExchangeOnlineDLMemberList |
        Select-Object -Property *, @{Name = 'UserID'; Expression = {$_.ID}}

Now we can compare both lists and output the items where the properties we use to compare are the same:

Compare-Object -ReferenceObject $SPOSiteList -DifferenceObject $EOCompareList -Property UserID -IncludeEqual -ExcludeDifferent -PassThru

… an additional tip:
Especially for cmdlets where you have to provide a lot of values for parameters with long names it is recommended to use splatting. Here you can read more about:

Using splatting the last code snippet would look like this then:

$CompareObjectSplat = @{
    ReferenceObject  = $SPOSiteList
    DifferenceObject = $EOCompareList
    Property         = 'UserID'
    IncludeEqual     = $true
    ExcludeDifferent = $true
    PassThru         = $true
Compare-Object @CompareObjectSplat