Forum Discussion

TheGarrison's avatar
TheGarrison
Copper Contributor
Feb 24, 2023
Solved

Powershell Query - Sum / Total / Count

Hi,

When i run this : 

 

Get-CsOnlineUser | Where-Object { $_.AssignedPlan -like "MCOEV_VirtualUSER" } | select UserPrincipalName, LineURI

 

It works fine and returns all the objects i would expect to see.

 

Now all i want to do is get a sum total of the objects as a number e.g 89 , i can do this on EXO Powershell for users/mailboxes but not in Teams PWS ive tried both :

 

$sum = (Get-CsOnlineUser | Where-Object { $_.AssignedPlan -like "MCOEV_VirtualUSER" }).sum

 

&

 

(Get-CsOnlineUser | Where-Object { $_.AssignedPlan -like "MCOEV_VirtualUSER" }).sum

 

 

Both complete without error but also do not produce/return any value.

 

What am i missing here?

 

Regards

 

  • TheGarrison I'm pretty sure you should be using Count not Sum, there isn't anything to add up.

     

    It's perhaps a quirk that sum works in other places, should all be using Count in my opinion.

     

    (Get-CsOnlineUser | Where-Object { $_.AssignedPlan -like "MCOEV_VirtualUSER" }).Count

1 Reply

  • TheGarrison I'm pretty sure you should be using Count not Sum, there isn't anything to add up.

     

    It's perhaps a quirk that sum works in other places, should all be using Count in my opinion.

     

    (Get-CsOnlineUser | Where-Object { $_.AssignedPlan -like "MCOEV_VirtualUSER" }).Count

Resources