You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Modules/CIPPCore/Public/Clear-CIPPImmutableId.ps1
+60-3Lines changed: 60 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,69 @@ function Clear-CIPPImmutableId {
3
3
param (
4
4
$TenantFilter,
5
5
$UserID,
6
+
$Username,# Optional - used for better logging and scheduling messages
7
+
$User,# Optional - if provided, will check sync status and schedule if needed
6
8
$Headers,
7
9
$APIName='Clear Immutable ID'
8
10
)
9
11
10
12
try {
13
+
# If User object is provided, check if we need to schedule instead of clearing immediately
14
+
if ($User) {
15
+
# User has ImmutableID but is not synced from on-premises - safe to clear immediately
16
+
if ($User.onPremisesSyncEnabled-ne$true-and![string]::IsNullOrEmpty($User.onPremisesImmutableId)) {
17
+
$DisplayName=$Username??$UserID
18
+
Write-LogMessage-Message "User $DisplayName has an ImmutableID set but is not synced from on-premises. Proceeding to clear the ImmutableID."-TenantFilter $TenantFilter-Severity 'Warning'-APIName $APIName-headers $Headers
19
+
# Continue to clear below
20
+
}
21
+
# User is synced from on-premises - must schedule for after deletion
Write-LogMessage-Message "User $DisplayName is synced from on-premises. Scheduling an Immutable ID clear for when the user account has been soft deleted."-TenantFilter $TenantFilter-Severity 'Warning'-APIName $APIName-headers $Headers
0 commit comments