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
fix(ninjaone): improve error handling and dedup logic
- Replace silent Write-Information bulk error messages with structured Write-LogMessage calls including normalized error details and batch counts
- Handle duplicate document templates gracefully by selecting the oldest instead of throwing
- Clear stale user/update cache entries from Azure Table Storage at sync start rather than reusing potentially stale data
- Remove debug Write-Host from document template creation
Write-Warning"Multiple NinjaOne document templates named '$($Template.name)' found ($MatchedCount). Using the oldest (id $($NinjaDocumentTemplate.id)). Remove the duplicate template(s) in NinjaOne."
Write-Information"Bulk Creation Error, but may have been successful as only 1 record with an issue could have been the cause: $_"
1217
+
$ErrorMessage=Get-CippException-Exception $_
1218
+
Write-LogMessage-tenant $Customer.defaultDomainName-API 'NinjaOneSync'-message "NinjaOne user document creation failed for $($Customer.displayName). NinjaOne rejects the whole batch if any single document is invalid, so all $(($NinjaUserCreation|Measure-Object).count) user(s) in this batch were not written: $($ErrorMessage.NormalizedError)"-Sev 'Error'-LogData $ErrorMessage
1223
1219
}
1224
1220
1225
1221
try {
@@ -1231,7 +1227,8 @@ function Invoke-NinjaOneTenantSync {
Write-Information"Bulk Update Errored, but may have been successful as only 1 record with an issue could have been the cause: $_"
1230
+
$ErrorMessage=Get-CippException-Exception $_
1231
+
Write-LogMessage-tenant $Customer.defaultDomainName-API 'NinjaOneSync'-message "NinjaOne user document update failed for $($Customer.displayName). NinjaOne rejects the whole batch if any single document is invalid, so all $(($NinjaUserUpdates|Measure-Object).count) user(s) in this batch were not written: $($ErrorMessage.NormalizedError)"-Sev 'Error'-LogData $ErrorMessage
1235
1232
}
1236
1233
1237
1234
@@ -1294,7 +1291,8 @@ function Invoke-NinjaOneTenantSync {
1294
1291
1295
1292
}
1296
1293
} catch {
1297
-
Write-Information"Bulk Creation Error, but may have been successful as only 1 record with an issue could have been the cause: $_"
1294
+
$ErrorMessage=Get-CippException-Exception $_
1295
+
Write-LogMessage-tenant $Customer.defaultDomainName-API 'NinjaOneSync'-message "NinjaOne user document creation failed for $($Customer.displayName). NinjaOne rejects the whole batch if any single document is invalid, so all $(($NinjaUserCreation|Measure-Object).count) user(s) in this batch were not written: $($ErrorMessage.NormalizedError)"-Sev 'Error'-LogData $ErrorMessage
1298
1296
}
1299
1297
1300
1298
try {
@@ -1305,7 +1303,8 @@ function Invoke-NinjaOneTenantSync {
Write-Information"Bulk Update Errored, but may have been successful as only 1 record with an issue could have been the cause: $_"
1306
+
$ErrorMessage=Get-CippException-Exception $_
1307
+
Write-LogMessage-tenant $Customer.defaultDomainName-API 'NinjaOneSync'-message "NinjaOne user document update failed for $($Customer.displayName). NinjaOne rejects the whole batch if any single document is invalid, so all $(($NinjaUserUpdates|Measure-Object).count) user(s) in this batch were not written: $($ErrorMessage.NormalizedError)"-Sev 'Error'-LogData $ErrorMessage
1309
1308
}
1310
1309
1311
1310
### Relationship Mapping
@@ -1483,7 +1482,8 @@ function Invoke-NinjaOneTenantSync {
Write-Information"Bulk Creation Error, but may have been successful as only 1 record with an issue could have been the cause: $_"
1485
+
$ErrorMessage=Get-CippException-Exception $_
1486
+
Write-LogMessage-tenant $Customer.defaultDomainName-API 'NinjaOneSync'-message "NinjaOne license document creation failed for $($Customer.displayName). NinjaOne rejects the whole batch if any single document is invalid, so all $(($NinjaLicenseCreation|Measure-Object).count) license(s) in this batch were not written: $($ErrorMessage.NormalizedError)"-Sev 'Error'-LogData $ErrorMessage
1487
1487
}
1488
1488
1489
1489
try {
@@ -1494,7 +1494,8 @@ function Invoke-NinjaOneTenantSync {
1494
1494
Write-Information'Completed Update'
1495
1495
}
1496
1496
} catch {
1497
-
Write-Information"Bulk Update Errored, but may have been successful as only 1 record with an issue could have been the cause: $_"
1497
+
$ErrorMessage=Get-CippException-Exception $_
1498
+
Write-LogMessage-tenant $Customer.defaultDomainName-API 'NinjaOneSync'-message "NinjaOne license document update failed for $($Customer.displayName). NinjaOne rejects the whole batch if any single document is invalid, so all $(($NinjaLicenseUpdates|Measure-Object).count) license(s) in this batch were not written: $($ErrorMessage.NormalizedError)"-Sev 'Error'-LogData $ErrorMessage
0 commit comments