by PowerFree at 2012-12-20 01:01:46
Hi Folks,by nohandle at 2012-12-20 01:18:38
I am doing some PowerShell reporting for our mail server with Exchange Management console. I am querying for Quota properties on mailboxes and the output is like:
$IssueWarningQuota = 4 GB (4,294,967,296 bytes)
or
$IssueWarningQuota = 4.199 GB (4,508,876,800 bytes)
I would like to get rid of everything following GB
so "4 GB (4,294,967,296 bytes)" would become "4 GB"
and "4.199 GB (4,508,876,800 bytes)" would become "4.199 GB"
try this:by PowerFree at 2012-12-20 02:29:12$string = "4 GB (4,294,967,296 bytes)"
if ($string -match ".GB")
{
$matches[0]
}
HI,by nohandle at 2012-12-20 03:31:55
I tried the following:
[code2=powershell]$mbstats = get-mailbox $mb | where {$_.UseDatabaseQuotaDefaults -eq $False} | ft name,prohibit,issue*
if ($mb.IssueWarningQuota -match ".*GB")
{
$mb.IssueWarningQuota = $mb.IssueWarningQuota[0]
}
$userObj | Add-Member NoteProperty IssueWarningQuota -Value $mb.IssueWarningQuota
$userObj | Add-Member NoteProperty ProhibitSendQuota -Value $mb.ProhibitSendQuota
$userObj | Add-Member NoteProperty ProhibitSendReceiveQuota -Value $mb.ProhibitSendReceiveQuota[/code2]
But it still returns "4 GB (4,294,967,296 bytes)"
The resulting value is saved in the $matches[0] not in $mb.IssueWarningQuota[0].by PowerFree at 2012-12-20 04:50:05
Does this work?$mb.IssueWarningQuota = $matches[0]
It works! thanks a lotby nohandle at 2012-12-20 05:55:39
You are welcome. If the issue is solved please mark the thread as solved by the solved button.