Skip to content

Commit 6185889

Browse files
committed
prevent int parsing errors with mailbox stats
1 parent 226e79d commit 6185889

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ListUserMailboxDetails.ps1

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,22 @@ Function Invoke-ListUserMailboxDetails {
136136
$MailboxDetailedRequest.ForwardingSmtpAddress
137137
}
138138

139+
$ProhibitSendQuotaString = $MailboxDetailedRequest.ProhibitSendQuota -split ' '
140+
$ProhibitSendReceiveQuotaString = $MailboxDetailedRequest.ProhibitSendReceiveQuota -split ' '
141+
$TotalItemSizeString = $StatsRequest.TotalItemSize -split ' '
142+
$TotalArchiveItemSizeString = $ArchiveSizeRequest.TotalItemSize -split ' '
143+
144+
$ProhibitSendQuota = try { [math]::Round([float]($ProhibitSendQuotaString[0]), 2) } catch { 0 }
145+
$ProhibitSendReceiveQuota = try { [math]::Round([float]($ProhibitSendReceiveQuotaString[0]), 2) } catch { 0 }
146+
147+
$ItemSizeType = '1{0}' -f ($TotalItemSizeString[1] ?? 'Gb')
148+
$TotalItemSize = try { [math]::Round([float]($TotalItemSizeString[0]) / $ItemSizeType, 2) } catch { 0 }
149+
150+
if ($ArchiveEnabled) {
151+
$ArchiveSizeType = '1{0}' -f ($TotalArchiveItemSizeString[1] ?? 'Gb')
152+
$TotalArchiveItemSize = [math]::Round([float]($TotalArchiveItemSizeString[0]) / $ArchiveSizeType, 2)
153+
}
154+
139155
# Build the GraphRequest object
140156
$GraphRequest = [ordered]@{
141157
ForwardAndDeliver = $MailboxDetailedRequest.DeliverToMailboxAndForward
@@ -149,12 +165,12 @@ Function Invoke-ListUserMailboxDetails {
149165
MailboxPopEnabled = $CASRequest.PopEnabled
150166
MailboxActiveSyncEnabled = $CASRequest.ActiveSyncEnabled
151167
Permissions = @($ParsedPerms)
152-
ProhibitSendQuota = [math]::Round([float]($MailboxDetailedRequest.ProhibitSendQuota -split ' GB')[0], 2)
153-
ProhibitSendReceiveQuota = [math]::Round([float]($MailboxDetailedRequest.ProhibitSendReceiveQuota -split ' GB')[0], 2)
168+
ProhibitSendQuota = $ProhibitSendQuota
169+
ProhibitSendReceiveQuota = $ProhibitSendReceiveQuota
154170
ItemCount = [math]::Round($StatsRequest.ItemCount, 2)
155-
TotalItemSize = [math]::Round($StatsRequest.TotalItemSize / 1Gb, 2)
156-
TotalArchiveItemSize = if ($ArchiveEnabled) { [math]::Round($ArchiveSizeRequest.TotalItemSize / 1Gb, 2) } else { '0' }
157-
TotalArchiveItemCount = if ($ArchiveEnabled) { [math]::Round($ArchiveSizeRequest.ItemCount, 2) } else { 0 }
171+
TotalItemSize = $TotalItemSize
172+
TotalArchiveItemSize = if ($ArchiveEnabled) { $TotalArchiveItemSize } else { '0' }
173+
TotalArchiveItemCount = if ($ArchiveEnabled) { try { [math]::Round($ArchiveSizeRequest.ItemCount, 2) } catch { 0 } } else { 0 }
158174
BlockedForSpam = $BlockedForSpam
159175
ArchiveMailBox = $ArchiveEnabled
160176
AutoExpandingArchive = $AutoExpandingArchiveEnabled

0 commit comments

Comments
 (0)