swan_solutions
asked on
Formatting mailbox size results in PowerShell
We are currently working on a PowerShell script to determine what the warning limits are for mailboxes in 365 and to change them, as requested by our client.
We have the script working and it gives us the results we need but what we would like to do is remove the bytes size which is shown alongside the results '61.9 MB (64,902,919 bytes)'
Is it possible to remove the bytes so it only shows 61.9Mb
Any comments or assistance would be greatly appreciated.
We have the script working and it gives us the results we need but what we would like to do is remove the bytes size which is shown alongside the results '61.9 MB (64,902,919 bytes)'
Is it possible to remove the bytes so it only shows 61.9Mb
Any comments or assistance would be greatly appreciated.
#ADD THE 365 ADMIN USER DETAILS
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
#VIEW INFORMATION OF ALL MAILBOXES
Get-Mailbox | Select-Object Displayname,identity,PrimarySmtpAddress,@{Name='TotalItemSize (GB)'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).TotalItemSize))}},@{Name='ItemCount'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).ItemCount))}},IssueWarningQuota, ProhibitSendQuota | Format-Table
#PUSH ANY KEY TO CONTINUE - LETTING THE TECHNICIAN USING THE SCRIPT TO REVIEW THE RESULTS
Read-Host -Prompt "Press Enter to continue"
#CREATE THE MINIMISE OBJECT
$shell = New-Object -ComObject "Shell.Application"
$shell.minimizeall() #Minimize all windows
#TEXT BOX NEEDING THE EMAIL ADDRESS TO BE CHANGED
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
$User = [Microsoft.VisualBasic.Interaction]::InputBox('Enter the email address to change', 'Email alert quote change')
#TEXTBOX FOR THE SIZES
$VARIssueWarningQuota = [Microsoft.VisualBasic.Interaction]::InputBox('Issue Warning Quota change. Enter value and size type, e.g. 10gb for 10 GigaBytes', 'Issue Warning Quota')
#MAXIMISE ALL WINDOWS
$shell = New-Object -ComObject "Shell.Application"
$shell.undominimizeall()
#CHANGE QUOTAS USING THE VARIABLED ENTERED IN LINE 21
Set-Mailbox $user -id -IssueWarningQuota $VARIssueWarningQuota
#GET UPDATED QUOTE INFORMATION
Get-Mailbox $User | Select-Object Displayname,Database,@{Name='TotalItemSize'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).TotalItemSize))}},@{Name='ItemCount'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).ItemCount))}},IssueWarningQuota, ProhibitSendQuota
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And if you want the totalitemsSize in mb would be like this:
#ADD THE 365 ADMIN USER DETAILS
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
#VIEW INFORMATION OF ALL MAILBOXES
Get-Mailbox -ResultSize unlimited| Select-Object Displayname,identity,PrimarySmtpAddress,@{Name='TotalItemSize (MB)'; Expression={[math]::Round((((Get-MailboxStatistics -identity $_.identity).TotalItemSize.ToString()).Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}},@{Name='ItemCount'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).ItemCount))}},@{name="IssueWarningQuota (GB)";expression={ ($_.IssueWarningQuota.ToString()).Split("(")[0]}},@{name="ProhibitSendQuota (GB)";expression={($_.ProhibitSendQuota.ToString()).Split("(")[0]}} | Format-Table
#PUSH ANY KEY TO CONTINUE - LETTING THE TECHNICIAN USING THE SCRIPT TO REVIEW THE RESULTS
Read-Host -Prompt "Press Enter to continue"
#CREATE THE MINIMISE OBJECT
$shell = New-Object -ComObject "Shell.Application"
$shell.minimizeall() #Minimize all windows
#TEXT BOX NEEDING THE EMAIL ADDRESS TO BE CHANGED
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
$User = [Microsoft.VisualBasic.Interaction]::InputBox('Enter the email address to change', 'Email alert quote change')
#TEXTBOX FOR THE SIZES
$VARIssueWarningQuota = [Microsoft.VisualBasic.Interaction]::InputBox('Issue Warning Quota change. Enter value and size type, e.g. 10gb for 10 GigaBytes', 'Issue Warning Quota')
#MAXIMISE ALL WINDOWS
$shell = New-Object -ComObject "Shell.Application"
$shell.undominimizeall()
#CHANGE QUOTAS USING THE VARIABLED ENTERED IN LINE 21
Set-Mailbox $user -id -IssueWarningQuota $VARIssueWarningQuota
#GET UPDATED QUOTE INFORMATION
#Get-Mailbox | Select-Object Displayname,identity,PrimarySmtpAddress,@{Name='TotalItemSize (GB)'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).TotalItemSize))}},@{Name='ItemCount'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).ItemCount))}},IssueWarningQuota, ProhibitSendQuota | Format-Table
Get-Mailbox -ResultSize unlimited| Select-Object Displayname,identity,PrimarySmtpAddress,@{Name='TotalItemSize (MB)'; Expression={[math]::Round((((Get-MailboxStatistics -identity $_.identity).TotalItemSize.ToString()).Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}},@{Name='ItemCount'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).ItemCount))}},@{name="IssueWarningQuota (GB)";expression={ ($_.IssueWarningQuota.ToString()).Split("(")[0]}},@{name="ProhibitSendQuota (GB)";expression={($_.ProhibitSendQuota.ToString()).Split("(")[0]}} | Format-Table
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I have recommended this question be closed as follows:
Accept: Jose [MCSE] Ortega C (https:#a42384597)
If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.
Pber
Experts-Exchange Cleanup Volunteer
I have recommended this question be closed as follows:
Accept: Jose [MCSE] Ortega C (https:#a42384597)
If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.
Pber
Experts-Exchange Cleanup Volunteer
ASKER