List not-found AD accounts individually in the log

This commit is contained in:
2026-02-27 10:26:00 +11:00
parent 666fdf94b1
commit 8aa4c8b3bd

View File

@@ -52,6 +52,7 @@ $emailUpdates = 0
$disables = 0
$noChanges = 0
$notFound = 0
$notFoundList = @()
foreach ($entry in $Deduped.Values) {
$samAccount = $entry.PAYROLL_REC_NO.Trim()
@@ -65,6 +66,7 @@ foreach ($entry in $Deduped.Values) {
-ErrorAction Stop
} catch {
$notFound++
$notFoundList += $samAccount
continue
}
@@ -115,5 +117,10 @@ Write-Log " Email updates : $emailUpdates"
Write-Log " Accounts disabled : $disables"
Write-Log " No changes needed : $noChanges"
Write-Log " Not found in AD : $notFound"
if ($notFoundList.Count -gt 0) {
foreach ($missing in $notFoundList) {
Write-Log " - $missing" "Yellow"
}
}
Write-Log $RunHeader
Write-Log ""