简体   繁体   中英

Simplify output of "Get-Mailbox| select ProhibitSendQuota" - Exchange, Powershell


I was wondering how i could get the output from Get-Mailbox| select ProhibitSendQuotaGet-Mailbox| select ProhibitSendQuota without the size displayed in Bytes behind GB?

if you run Get-Mailbox| select ProhibitSendQuota Get-Mailbox| select ProhibitSendQuota , you get something like:

ProhibitSendQuota             
-----------------             
49.5 GB (53,150,220,288 bytes)
49.5 GB (53,150,220,288 bytes)
49.5 GB (53,150,220,288 bytes)

I would like the output to look more like (If possible) :

ProhibitSendQuota             
-----------------             
          49.5 GB
          49.5 GB
          49.5 GB

Any help with this would be very nice! its not a dealbreaker. but it would makes it so much more clean and readable.

The solution was as @AdminOfThings commented.

Get-Mailbox| select @{n='ProhibitSendQuota';e={$_.ProhibitSendQuota -replace '\s*\(.*$' }}

I'm using it within this

$Result += New-Object -TypeName PSObject -Property $([ordered]@{ 
    UserName                    = $mbx.DisplayName
    Epost                       = $mbx.UserPrincipalName
    ArchiveStatus               = $mbx.ArchiveStatus
    ArchiveName                 = $mbx.ArchiveName
    ArchiveState                = $mbx.ArchiveState
    MailBoxQuota                = $mbx.ProhibitSendQuota -replace '\s*\(.*$'
    'Archive Size (GB)'         = $size
    ArchiveWarningQuota         = if ($mbx.ArchiveStatus -eq "Active") { $mbx.ArchiveWarningQuota } Else { $null } 
    ArchiveQuota                = if ($mbx.ArchiveStatus -eq "Active") { $mbx.ArchiveQuota -replace '\s*\(.*$'} Else { $null } 
    AutoExpArchive              = $mbx.AutoExpandingArchiveEnabled
    'TotalItemSize (GB)'        = [math]::Round((($mbs.TotalItemSize.Value.ToString()).Split("(")[1].Split(" ")[0].Replace(",", "") / 1GB), 2)
    ItemCount                   = $mbs.ItemCount
    LastLogonTime               = $mbs.LastLogonTime
}

and it works great!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM