none
mailbox stats RRS feed

  • Question

  • Hi Experts i want to get the below information, i am getting to write the ps1 please help me correct it

    foreach($users in Get-Mailbox -ResultSize Unlimited){$users | Foreach-Object {   
    $user = $_
    $stats = Get-MailboxStatistics $user.Name
    $a=get-user $user.name
    New-Object -TypeName PSObject -Property @{       
    DisplayName = $User.DisplayName
    FirstName = $a.FirstName
    LastName = $a.lastname
    userprincipalname = $user.userprincipalname
    AuditEnabled = $User.AuditEnabled  
    Primary SMTP Address =
    Secondary SMTP Adress =
    Alais =            

    }
    }

    Wednesday, July 3, 2019 11:53 PM

Answers

  • Hi Risingflight,

    Remove blank from  "Primary SMTP Address":

    PrimarySMTPAddress = $User.PrimarySmtpAddress
    Alais = $User.Alias

    About "Secondary SMTP Adress" property, you cannot just get it without primary smtp address, there only a parameter related with it: EmailAddresses

    SMTPAdress = $User.EmailAddresses

    So, the full script is:

    foreach($users in Get-Mailbox -ResultSize Unlimited){$users | Foreach-Object {
        $user = $_
        $stats = Get-MailboxStatistics $user.Name
        $a=get-user $user.name
    
        New-Object -TypeName PSObject -Property @{       
        DisplayName = $User.DisplayName
        FirstName = $a.FirstName
        LastName = $a.lastname
        userprincipalname = $user.userprincipalname
        AuditEnabled = $User.AuditEnabled  
        PrimarySMTPAddress = $User.PrimarySmtpAddress
        SMTPAdress = $User.EmailAddresses
        Alais = $User.Alias
    } 
    }
    }

    Regards,

    Kyle Xu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Thursday, July 4, 2019 6:13 AM
    Moderator

All replies

  • Hi Risingflight,

    Remove blank from  "Primary SMTP Address":

    PrimarySMTPAddress = $User.PrimarySmtpAddress
    Alais = $User.Alias

    About "Secondary SMTP Adress" property, you cannot just get it without primary smtp address, there only a parameter related with it: EmailAddresses

    SMTPAdress = $User.EmailAddresses

    So, the full script is:

    foreach($users in Get-Mailbox -ResultSize Unlimited){$users | Foreach-Object {
        $user = $_
        $stats = Get-MailboxStatistics $user.Name
        $a=get-user $user.name
    
        New-Object -TypeName PSObject -Property @{       
        DisplayName = $User.DisplayName
        FirstName = $a.FirstName
        LastName = $a.lastname
        userprincipalname = $user.userprincipalname
        AuditEnabled = $User.AuditEnabled  
        PrimarySMTPAddress = $User.PrimarySmtpAddress
        SMTPAdress = $User.EmailAddresses
        Alais = $User.Alias
    } 
    }
    }

    Regards,

    Kyle Xu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Thursday, July 4, 2019 6:13 AM
    Moderator
  • Hi Risingflight,

    I am writing here to confirm with you how thing going now?

    If the above suggestion helps, please be free to mark it as an answer for helping more people.

    Regards,

    Kyle Xu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Wednesday, July 10, 2019 6:29 AM
    Moderator