How to get the list of accounts with General as Employee number along with Mailbox and OneDrvie quota

Mani 376 Reputation points
2025-03-07T18:22:46.9+00:00

Hello all,

Is there way to pull a report for all generic accounts having General as Employee number along with Mailbox and OneDrive quota and last login details.

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,785 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Alex Zhang-MSFT 6,230 Reputation points Microsoft External Staff
    2025-03-10T03:03:51.9533333+00:00

    Hello, @Mani

    Welcome to the Microsoft Q&A platform!

    I can help you to pull a report for all generic accounts having General as Employee number along with Mailbox quota and last login details using PowerShell if you're working with Microsoft Exchange or Office 365.

    Here's a script that can help you get the details for generic accounts with "General" as the Employee number, along with their mailbox quota and last login details:

    Connect-ExchangeOnline
    
    # Get all mailboxes
    $mailboxes = Get-Mailbox -ResultSize Unlimited
    
    # Filter mailboxes with Employee number "General"
    $filteredMailboxes = $mailboxes | Where-Object { $_.EmployeeID -eq "General" }
    
    # Prepare the report
    $report = @()
    foreach ($mailbox in $filteredMailboxes) {
        $mailboxStats = Get-MailboxStatistics -Identity $mailbox.Alias
        $mailboxQuota = Get-Mailbox -Identity $mailbox.Alias | Select-Object -ExpandProperty ProhibitSendReceiveQuota
    
        $report += [PSCustomObject]@{
            DisplayName = $mailbox.DisplayName
            EmailAddress = $mailbox.PrimarySmtpAddress
            MailboxQuota = $mailboxQuota
            LastLoginTime = $mailboxStats.LastLogonTime
        }
    }
    
    # Export the report to a CSV file
    $report | Export-Csv -Path "C:\MailboxReport.csv" -NoTypeInformation
    

    This script connects to Exchange Online, retrieves all mailboxes, filters those with "General" as the Employee number, and then gathers the mailbox quota and last login details. Finally, it exports the report to a CSV file.

    Test results:

    User's image

    Since my account lacks the “$.EmployeeID” parameter that you need, I used the “$.UserPrincipalName” parameter in my test environment instead, so only one user's information is exported, you can modify it according to the script I provided above.

    Regarding the OneDrive quota part, since I don't have much knowledge about OneDrive products, I have discussed this issue with my colleague in charge of OneDrive. You can refer to this document to make changes to your script : Microsoft 365: Get OneDrive for Business Usage Report using PowerShell - SharePoint Diary.

    (Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.)


    If the answer is helpful, please click on “Accept answer” as it could help other members of the Microsoft Q&A community who have similar questions and are looking for solutions.

    Thank you for your support and understanding.

    Best Wishes,

    Alex Zhang

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.