Skip to content

Commit 64c89bd

Browse files
committed
Addition of InPlaceHold, EDiscoverHold, PurviewRetentionHold and ExcludedFromOrgWideHold
1 parent cfb922f commit 64c89bd

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Administration/Invoke-ListMailboxes.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Function Invoke-ListMailboxes {
1717
# Interact with query parameters or the body of the request.
1818
$TenantFilter = $Request.Query.tenantFilter
1919
try {
20-
$Select = 'id,ExchangeGuid,ArchiveGuid,UserPrincipalName,DisplayName,PrimarySMTPAddress,RecipientType,RecipientTypeDetails,EmailAddresses,WhenSoftDeleted,IsInactiveMailbox,ForwardingSmtpAddress,DeliverToMailboxAndForward,ForwardingAddress,HiddenFromAddressListsEnabled,ExternalDirectoryObjectId,MessageCopyForSendOnBehalfEnabled,MessageCopyForSentAsEnabled,PersistedCapabilities,LitigationHoldEnabled,LitigationHoldDate,LitigationHoldDuration,ComplianceTagHoldApplied,RetentionHoldEnabled'
20+
$Select = 'id,ExchangeGuid,ArchiveGuid,UserPrincipalName,DisplayName,PrimarySMTPAddress,RecipientType,RecipientTypeDetails,EmailAddresses,WhenSoftDeleted,IsInactiveMailbox,ForwardingSmtpAddress,DeliverToMailboxAndForward,ForwardingAddress,HiddenFromAddressListsEnabled,ExternalDirectoryObjectId,MessageCopyForSendOnBehalfEnabled,MessageCopyForSentAsEnabled,PersistedCapabilities,LitigationHoldEnabled,LitigationHoldDate,LitigationHoldDuration,ComplianceTagHoldApplied,RetentionHoldEnabled,InPlaceHolds'
2121
$ExoRequest = @{
2222
tenantid = $TenantFilter
2323
cmdlet = 'Get-Mailbox'
@@ -76,6 +76,7 @@ Function Invoke-ListMailboxes {
7676
@{ Name = 'LicensedForLitigationHold'; Expression = { ($_.PersistedCapabilities -contains 'BPOS_S_DlpAddOn' -or $_.PersistedCapabilities -contains 'BPOS_S_Enterprise') } },
7777
ComplianceTagHoldApplied,
7878
RetentionHoldEnabled,
79+
InPlaceHolds,
7980

8081
$StatusCode = [HttpStatusCode]::OK
8182
} catch {

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,50 @@ function Invoke-ListUserMailboxDetails {
177177
$TotalArchiveItemCount = try { [math]::Round($ArchiveSizeRequest.ItemCount, 2) } catch { 0 }
178178
}
179179

180+
# Parse InPlaceHolds to determine hold types if avaliable
181+
$InPlaceHold = $false
182+
$EDiscoveryHold = $false
183+
$PurviewRetentionHold = $false
184+
$ExcludedFromOrgWideHold = $false
185+
186+
# Check if InPlaceHolds property exists and has values
187+
if ($MailboxDetailedRequest.InPlaceHolds) {
188+
foreach ($hold in $MailboxDetailedRequest.InPlaceHolds) {
189+
# eDiscovery hold - starts with UniH
190+
if ($hold -like 'UniH*') {
191+
$EDiscoveryHold = $true
192+
}
193+
# In-Place Hold - no prefix or starts with cld
194+
# Check if it doesn't match any of the other known prefixes
195+
elseif (($hold -like 'cld*' -or
196+
($hold -notlike 'UniH*' -and
197+
$hold -notlike 'mbx*' -and
198+
$hold -notlike 'skp*' -and
199+
$hold -notlike '-mbx*'))) {
200+
$InPlaceHold = $true
201+
}
202+
# Microsoft Purview retention policy - starts with mbx or skp
203+
elseif ($hold -like 'mbx*' -or $hold -like 'skp*') {
204+
$PurviewRetentionHold = $true
205+
}
206+
# Excluded from organization-wide Microsoft Purview retention policy - starts with -mbx
207+
elseif ($hold -like '-mbx*') {
208+
$ExcludedFromOrgWideHold = $true
209+
}
210+
}
211+
}
212+
180213
# Build the GraphRequest object
181214
$GraphRequest = [ordered]@{
182215
ForwardAndDeliver = $MailboxDetailedRequest.DeliverToMailboxAndForward
183216
ForwardingAddress = $ForwardingAddress
184217
LitigationHold = $MailboxDetailedRequest.LitigationHoldEnabled
185218
RetentionHold = $MailboxDetailedRequest.RetentionHoldEnabled
186219
ComplianceTagHold = $MailboxDetailedRequest.ComplianceTagHoldApplied
220+
InPlaceHold = $InPlaceHold
221+
EDiscoveryHold = $EDiscoveryHold
222+
PurviewRetentionHold = $PurviewRetentionHold
223+
ExcludedFromOrgWideHold = $ExcludedFromOrgWideHold
187224
HiddenFromAddressLists = $MailboxDetailedRequest.HiddenFromAddressListsEnabled
188225
EWSEnabled = $CASRequest.EwsEnabled
189226
MailboxMAPIEnabled = $CASRequest.MAPIEnabled

0 commit comments

Comments
 (0)