How to fetch Top User of Office 365 and sort it by Traffic by using powershell

Efa Shahira 20 Reputation points
2024-01-09T01:57:32.28+00:00

I'm currently working on retrieving specific information from Office 365, and I'm facing challenges with the script. The script is currently returning only the usernames, and I also need to sort the output in descending order for traffic.

Additionally, I'd like to filter the results to only include users from a specific domain.

Here's the script I've tried:

Actually i want to retrieve the output as same as the portal like this

User's image

$outputTable = Get-MsolUser  |     Sort-Object -Property trafficTotalBytes -Descending |     Select-Object -First 10 UserPrincipalName, @{N='Total (GB)';E={"{0:N2}" -f ($_.trafficTotalBytes/1GB)}}  # Display the table $outputTable | Format-Table -AutoSize 
Microsoft Office Online Server
Microsoft Office Online Server
Microsoft on-premises server product that runs Office Online. Previously known as Office Web Apps Server.
604 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,212 questions
Microsoft Defender for Cloud Apps
Microsoft Defender for Cloud Apps
A Microsoft cloud access security broker that enables customers to control the access and use of software as a service apps in their organization.
115 questions
0 comments No comments
{count} votes