@@ -296,7 +296,8 @@ function Invoke-NinjaOneTenantSync {
296296 $AllGroups = $ExtensionCache.Groups
297297 $Licenses = $ExtensionCache.Licenses
298298 $RawDomains = $ExtensionCache.Domains
299- $AllConditionalAccessPolicies = $ExtensionCache.ConditionalAccessPolicies
299+ $AllConditionalAccessPolicies = $ExtensionCache.ConditionalAccess
300+ Write-Output " DEBUG: AllConditionalAccessPolicies Count: $ ( $AllConditionalAccessPolicies.Count ) "
300301
301302 $CurrentSecureScore = ($SecureScore | Sort-Object createDateTime - Descending | Select-Object - First 1 )
302303 $MaxSecureScoreRank = ($SecureScoreProfiles.rank | Measure-Object - Maximum).maximum
@@ -780,15 +781,14 @@ function Invoke-NinjaOneTenantSync {
780781 }
781782 }
782783
783-
784784 # $PermsRequest = ''
785785 $StatsRequest = ' '
786786 $MailboxDetailedRequest = ' '
787787 $CASRequest = ' '
788788
789789 $CASRequest = $CASFull | Where-Object { $_.ExternalDirectoryObjectId -eq $User.iD }
790790 $MailboxDetailedRequest = $MailboxDetailedFull | Where-Object { $_.ExternalDirectoryObjectId -eq $User.iD }
791- $StatsRequest = $MailboxStatsFull | Where-Object { $_ .' User Principal Name ' -eq $User.UserPrincipalName }
791+ $StatsRequest = $MailboxStatsFull | Where-Object { $_.userPrincipalName -eq $User.UserPrincipalName }
792792
793793
794794 $ParsedPerms = foreach ($Perm in $Permissions ) {
@@ -801,15 +801,15 @@ function Invoke-NinjaOneTenantSync {
801801 }
802802
803803 try {
804- $TotalItemSize = [math ]::Round($StatsRequest .' Storage Used (Byte) ' / 1 Gb , 2 )
804+ $TotalItemSize = [math ]::Round($StatsRequest.storageUsedInBytes / 1 Gb , 2 )
805805 } catch {
806806 $TotalItemSize = 0
807807 }
808808
809809 $UserMailSettings = [pscustomobject ]@ {
810810 ForwardAndDeliver = $MailboxDetailedRequest.DeliverToMailboxAndForward
811811 ForwardingAddress = $MailboxDetailedRequest.ForwardingAddress + ' ' + $MailboxDetailedRequest.ForwardingSmtpAddress
812- LitigationHold = $MailboxDetailedRequest.LitigationHoldEnabled
812+ LitigationHold = $MailboxDetailedRequest.LitigationHoldEnabled
813813 HiddenFromAddressLists = $MailboxDetailedRequest.HiddenFromAddressListsEnabled
814814 EWSEnabled = $CASRequest.EwsEnabled
815815 MailboxMAPIEnabled = $CASRequest.MAPIEnabled
@@ -818,10 +818,11 @@ function Invoke-NinjaOneTenantSync {
818818 MailboxPopEnabled = $CASRequest.PopEnabled
819819 MailboxActiveSyncEnabled = $CASRequest.ActiveSyncEnabled
820820 Permissions = $ParsedPerms
821- ProhibitSendQuota = [math ]::Round([float ]($MailboxDetailedRequest.ProhibitSendQuota -split ' GB' )[0 ], 2 )
822- ProhibitSendReceiveQuota = [math ]::Round([float ]($MailboxDetailedRequest.ProhibitSendReceiveQuota -split ' GB' )[0 ], 2 )
823- ItemCount = [math ]::Round($StatsRequest .' Item Count' , 2 )
824- TotalItemSize = $TotalItemSize
821+ ProhibitSendQuota = $StatsRequest.prohibitSendQuotaInBytes
822+ ProhibitSendReceiveQuota = $StatsRequest.prohibitSendReceiveQuotaInBytes
823+ ItemCount = [math ]::Round($StatsRequest.itemCount , 2 )
824+ TotalItemSize = $StatsRequest.totalItemSize
825+ StorageUsedInBytes = $StatsRequest.storageUsedInBytes
825826 }
826827
827828
@@ -872,9 +873,9 @@ function Invoke-NinjaOneTenantSync {
872873
873874
874875
875- $UserOneDriveStats = $OneDriveDetails | Where-Object { $_ .' Owner Principal Name ' -eq $User.userPrincipalName } | Select-Object - First 1
876- $UserOneDriveUse = $UserOneDriveStats .' Storage Used (Byte) ' / 1 GB
877- $UserOneDriveTotal = $UserOneDriveStats .' Storage Allocated (Byte) ' / 1 GB
876+ $UserOneDriveStats = $OneDriveDetails | Where-Object { $_.ownerPrincipalName -eq $User.userPrincipalName } | Select-Object - First 1
877+ $UserOneDriveUse = $UserOneDriveStats.storageUsedInBytes / 1 GB
878+ $UserOneDriveTotal = $UserOneDriveStats.storageAllocatedInBytes / 1 GB
878879
879880 if ($UserOneDriveTotal ) {
880881 $OneDriveUse = [PSCustomObject ]@ {
@@ -908,13 +909,13 @@ function Invoke-NinjaOneTenantSync {
908909
909910 if ($UserOneDriveStats ) {
910911 $OneDriveCardData = [PSCustomObject ]@ {
911- ' One Drive URL' = ' <a href="' + ($UserOneDriveStats .' Site URL ' ) + ' ">' + ($UserOneDriveStats .' Site URL ' ) + ' </a>'
912- ' Is Deleted' = " $ ( $UserOneDriveStats .' Is Deleted ' ) "
913- ' Last Activity Date' = " $ ( $UserOneDriveStats .' Last Activity Date ' ) "
914- ' File Count' = " $ ( $UserOneDriveStats .' File Count ' ) "
915- ' Active File Count' = " $ ( $UserOneDriveStats .' Active File Count ' ) "
916- ' Storage Used (Byte)' = " $ ( $UserOneDriveStats .' Storage Used (Byte) ' ) "
917- ' Storage Allocated (Byte)' = " $ ( $UserOneDriveStats .' Storage Allocated (Byte) ' ) "
912+ ' One Drive URL' = ' <a href="' + ($UserOneDriveStats.siteUrl ) + ' ">' + ($UserOneDriveStats.siteUrl ) + ' </a>'
913+ ' Is Deleted' = " $ ( $UserOneDriveStats.isDeleted ) "
914+ ' Last Activity Date' = " $ ( $UserOneDriveStats.lastActivityDate ) "
915+ ' File Count' = " $ ( $UserOneDriveStats.fileCount ) "
916+ ' Active File Count' = " $ ( $UserOneDriveStats.activeFileCount ) "
917+ ' Storage Used (Byte)' = " $ ( $UserOneDriveStats.storageUsedInBytes ) "
918+ ' Storage Allocated (Byte)' = " $ ( $UserOneDriveStats.storageAllocatedInBytes ) "
918919 ' One Drive Usage' = $OneDriveParsed
919920
920921 }
@@ -925,9 +926,9 @@ function Invoke-NinjaOneTenantSync {
925926 }
926927
927928
928- $UserMailboxStats = $MailboxStatsFull | Where-Object { $_ .' User Principal Name ' -eq $User.userPrincipalName } | Select-Object - First 1
929- $UserMailUse = $UserMailboxStats .' Storage Used (Byte) ' / 1 GB
930- $UserMailTotal = $UserMailboxStats .' Prohibit Send/Receive Quota (Byte) ' / 1 GB
929+ $UserMailboxStats = $MailboxStatsFull | Where-Object { $_.userPrincipalName -eq $User.userPrincipalName } | Select-Object - First 1
930+ $UserMailUse = $UserMailboxStats.storageUsedInBytes / 1 GB
931+ $UserMailTotal = $UserMailboxStats.prohibitSendReceiveQuotaInBytes / 1 GB
931932
932933
933934 if ($UserMailTotal ) {
@@ -961,19 +962,30 @@ function Invoke-NinjaOneTenantSync {
961962
962963
963964 if ($UserMailSettings.ProhibitSendQuota ) {
965+ # Calculate GB values for display
966+ try {
967+ $MailboxProhibitSendQuota = [math ]::Round($UserMailSettings.ProhibitSendQuota / 1024 / 1024 / 1024 , 2 )
968+ $MailboxProhibitSendReceiveQuota = [math ]::Round($UserMailSettings.ProhibitSendReceiveQuota / 1024 / 1024 / 1024 , 2 )
969+ $MailboxStorageUsed = [math ]::Round($UserMailSettings.StorageUsedInBytes / 1024 / 1024 / 1024 , 2 )
970+ } catch {
971+ $MailboxProhibitSendQuota = 0
972+ $MailboxProhibitSendReceiveQuota = 0
973+ $MailboxStorageUsed = 0
974+ }
975+
964976 $MailboxDetailsCardData = [PSCustomObject ]@ {
965977 # 'Permissions' = "$($UserMailSettings.Permissions | ConvertTo-Html -Fragment | Out-String)"
966- ' Prohibit Send Quota' = " $ ( $UserMailSettings .ProhibitSendQuota ) "
967- ' Prohibit Send Receive Quota' = " $ ( $UserMailSettings .ProhibitSendReceiveQuota ) "
968- ' Item Count' = " $ ( $UserMailSettings.ProhibitSendReceiveQuota ) "
969- ' Total Mailbox Size' = " $ ( $UserMailSettings .ItemCount ) "
978+ ' Prohibit Send Quota' = " $ ( $MailboxProhibitSendQuota ) GB "
979+ ' Prohibit Send Receive Quota' = " $ ( $MailboxProhibitSendReceiveQuota ) GB "
980+ ' Item Count' = " $ ( $UserMailSettings.ItemCount ) "
981+ ' Total Mailbox Size' = " $ ( $MailboxStorageUsed ) GB "
970982 ' Mailbox Usage' = $MailboxParsed
971983 }
972984
973985 $MailboxSettingsCard = [PSCustomObject ]@ {
974986 ' Forward and Deliver' = " $ ( $UserMailSettings.ForwardAndDeliver ) "
975987 ' Forwarding Address' = " $ ( $UserMailSettings.ForwardingAddress ) "
976- ' Litigation Hold' = " $ ( $UserMailSettings.LitigationHold ) "
988+ ' Litigation Hold' = " $ ( $UserMailSettings.LitigationHold ) "
977989 ' Hidden From Address Lists' = " $ ( $UserMailSettings.HiddenFromAddressLists ) "
978990 ' EWS Enabled' = " $ ( $UserMailSettings.EWSEnabled ) "
979991 ' MAPI Enabled' = " $ ( $UserMailSettings.MailboxMAPIEnabled ) "
@@ -1809,7 +1821,7 @@ function Invoke-NinjaOneTenantSync {
18091821 }
18101822
18111823 # Recommended Actions HTML
1812- $RecommendedActionsHTML = $Top5Actions | Select-Object ' Recommended Action' , @ {n = ' Score Impact' ; e = { " +$ ( $_ .' Score Impact ' ) %" } }, Category, @ {n = ' Link' ; e = { ' <a href="' + $_.link + ' " target="_blank"><i class="fas fa-arrow-up-right-from-square" style="color: #337ab7;"></i></a>' } } | ConvertTo-Html -As Table - Fragment
1824+ $RecommendedActionsHTML = $Top5Actions | Select-Object ' Recommended Action' , @ {n = ' Score Impact' ; e = { " +$ ( $_.scoreImpact ) %" } }, Category, @ {n = ' Link' ; e = { ' <a href="' + $_.link + ' " target="_blank"><i class="fas fa-arrow-up-right-from-square" style="color: #337ab7;"></i></a>' } } | ConvertTo-Html -As Table - Fragment
18131825
18141826 $TitleLink = " https://security.microsoft.com/securescore?viewid=overview&tid=$ ( $Customer.customerId ) "
18151827
0 commit comments