|
1 | | -# Moved from EasyPIM/internal/functions/EPO_Write-EasyPIMSummary.ps1 |
| 1 | +function Write-EasyPIMSummary { |
| 2 | + [CmdletBinding()] |
| 3 | + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")] |
| 4 | + param ( |
| 5 | + [Parameter()] |
| 6 | + [PSCustomObject]$CleanupResults, |
| 7 | + |
| 8 | + [Parameter()] |
| 9 | + [PSCustomObject]$AssignmentResults, |
| 10 | + |
| 11 | + [Parameter()] |
| 12 | + [hashtable]$PolicyResults, |
| 13 | + |
| 14 | + [Parameter()] |
| 15 | + [string]$PolicyMode = "delta" |
| 16 | + ) |
| 17 | + |
| 18 | + Write-Host "`n┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓" -ForegroundColor Green |
| 19 | + Write-Host "┃ OVERALL SUMMARY ┃" -ForegroundColor Green |
| 20 | + Write-Host "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛" -ForegroundColor Green |
| 21 | + |
| 22 | + Write-Host "┌───────────────────────────────────────────────────────────────────────────────┐" -ForegroundColor White |
| 23 | + Write-Host "│ ASSIGNMENT CREATIONS" -ForegroundColor White |
| 24 | + Write-Host "├───────────────────────────────────────────────────────────────────────────────┤" -ForegroundColor White |
| 25 | + |
| 26 | + if ($null -ne $AssignmentResults) { |
| 27 | + $planned = if ($AssignmentResults.PSObject.Properties.Name -contains 'PlannedCreated') { $AssignmentResults.PlannedCreated } else { $null } |
| 28 | + Write-Host "│ ✅ Created : $($AssignmentResults.Created)" -ForegroundColor White |
| 29 | + if ($null -ne $planned) { |
| 30 | + Write-Host "│ 📝 Planned : $planned" -ForegroundColor White |
| 31 | + } |
| 32 | + Write-Host "│ ⏭️ Skipped : $($AssignmentResults.Skipped)" -ForegroundColor White |
| 33 | + Write-Host "│ ❌ Failed : $($AssignmentResults.Failed)" -ForegroundColor White |
| 34 | + } else { |
| 35 | + Write-Host "│ ✅ Created : 0" -ForegroundColor White |
| 36 | + Write-Host "│ ⏭️ Skipped : 0" -ForegroundColor White |
| 37 | + Write-Host "│ ❌ Failed : 0" -ForegroundColor White |
| 38 | + } |
| 39 | + Write-Host "└───────────────────────────────────────────────────────────────────────────────┘" -ForegroundColor White |
| 40 | + |
| 41 | + Write-Host "┌───────────────────────────────────────────────────────────────────────────────┐" -ForegroundColor White |
| 42 | + Write-Host "│ POLICY OPERATIONS" -ForegroundColor White |
| 43 | + Write-Host "├───────────────────────────────────────────────────────────────────────────────┤" -ForegroundColor White |
| 44 | + |
| 45 | + if ($null -ne $PolicyResults -and $null -ne $PolicyResults.Summary) { |
| 46 | + Write-Host "│ ✅ Applied : $($PolicyResults.Summary.Successful)" -ForegroundColor White |
| 47 | + Write-Host "│ ⏭️ Skipped : $($PolicyResults.Summary.Skipped)" -ForegroundColor White |
| 48 | + Write-Host "│ ❌ Failed : $($PolicyResults.Summary.Failed)" -ForegroundColor White |
| 49 | + Write-Host "│ 📋 Total : $($PolicyResults.Summary.TotalProcessed)" -ForegroundColor White |
| 50 | + } else { |
| 51 | + Write-Host "│ ✅ Applied : 0" -ForegroundColor White |
| 52 | + Write-Host "│ ⏭️ Skipped : 0" -ForegroundColor White |
| 53 | + Write-Host "│ ❌ Failed : 0" -ForegroundColor White |
| 54 | + Write-Host "│ 📋 Total : 0" -ForegroundColor White |
| 55 | + } |
| 56 | + Write-Host "└───────────────────────────────────────────────────────────────────────────────┘" -ForegroundColor White |
| 57 | + |
| 58 | + Write-Host "┌───────────────────────────────────────────────────────────────────────────────┐" -ForegroundColor White |
| 59 | + Write-Host "│ CLEANUP OPERATIONS" -ForegroundColor White |
| 60 | + Write-Host "├───────────────────────────────────────────────────────────────────────────────┤" -ForegroundColor White |
| 61 | + |
| 62 | + if ($null -ne $CleanupResults) { |
| 63 | + $kept = if ($null -ne $CleanupResults.KeptCount) { $CleanupResults.KeptCount } |
| 64 | + elseif ($null -ne $CleanupResults.Kept) { $CleanupResults.Kept } |
| 65 | + else { 0 } |
| 66 | + |
| 67 | + $removed = if ($null -ne $CleanupResults.RemovedCount) { $CleanupResults.RemovedCount } |
| 68 | + elseif ($null -ne $CleanupResults.Removed) { $CleanupResults.Removed } |
| 69 | + else { 0 } |
| 70 | + |
| 71 | + $skipped = if ($null -ne $CleanupResults.SkippedCount) { $CleanupResults.SkippedCount } |
| 72 | + elseif ($null -ne $CleanupResults.Skipped) { $CleanupResults.Skipped } |
| 73 | + else { 0 } |
| 74 | + |
| 75 | + $protected = if ($null -ne $CleanupResults.ProtectedCount) { $CleanupResults.ProtectedCount } |
| 76 | + elseif ($null -ne $CleanupResults.Protected) { $CleanupResults.Protected } |
| 77 | + else { 0 } |
| 78 | + |
| 79 | + Write-Host "│ ✅ Kept : $kept" -ForegroundColor White |
| 80 | + Write-Host "│ 🗑️ Removed : $removed" -ForegroundColor White |
| 81 | + if ($CleanupResults.PSObject.Properties.Name -contains 'WouldRemoveCount') { |
| 82 | + Write-Host "│ 🛈 WouldRemove: $($CleanupResults.WouldRemoveCount)" -ForegroundColor White |
| 83 | + if ($CleanupResults.PSObject.Properties.Name -contains 'WouldRemoveDetails' -and $CleanupResults.WouldRemoveDetails -and $CleanupResults.WouldRemoveDetails.Count -gt 0) { |
| 84 | + $previewSample = $CleanupResults.WouldRemoveDetails | Select-Object -First 5 |
| 85 | + foreach($item in $previewSample){ |
| 86 | + $sc = if ($item.Scope) { $item.Scope } else { '' } |
| 87 | + Write-Host "│ - $($item.RoleName) $sc $($item.PrincipalId)" -ForegroundColor DarkGray |
| 88 | + } |
| 89 | + if ($CleanupResults.WouldRemoveDetails.Count -gt 5) { |
| 90 | + Write-Host "│ ... (+$($CleanupResults.WouldRemoveDetails.Count - 5) more)" -ForegroundColor DarkGray |
| 91 | + } |
| 92 | + } |
| 93 | + if ($CleanupResults.PSObject.Properties.Name -contains 'WouldRemoveExportPath' -and $CleanupResults.WouldRemoveExportPath) { |
| 94 | + Write-Host "│ 📤 Export file: $($CleanupResults.WouldRemoveExportPath)" -ForegroundColor DarkGray |
| 95 | + } |
| 96 | + } |
| 97 | + Write-Host "│ ⏭️ Skipped : $skipped" -ForegroundColor White |
| 98 | + if ($protected -gt 0) { |
| 99 | + Write-Host "│ 🛡️ Protected: $protected" -ForegroundColor White |
| 100 | + } |
| 101 | + } else { |
| 102 | + Write-Host "│ ✅ Kept : 0" -ForegroundColor White |
| 103 | + Write-Host "│ 🗑️ Removed : 0" -ForegroundColor White |
| 104 | + Write-Host "│ ⏭️ Skipped : 0" -ForegroundColor White |
| 105 | + } |
| 106 | + Write-Host "└───────────────────────────────────────────────────────────────────────────────┘" -ForegroundColor White |
| 107 | + |
| 108 | + if ($script:EasyPIM_DeferredGroupPoliciesSummary) { |
| 109 | + $dg = $script:EasyPIM_DeferredGroupPoliciesSummary |
| 110 | + Write-Host "┌───────────────────────────────────────────────────────────────────────────────┐" -ForegroundColor White |
| 111 | + Write-Host "│ DEFERRED GROUP POLICIES" -ForegroundColor White |
| 112 | + Write-Host "├───────────────────────────────────────────────────────────────────────────────┤" -ForegroundColor White |
| 113 | + Write-Host "│ ✅ Applied : $($dg.Applied)" -ForegroundColor White |
| 114 | + Write-Host "│ ⏳ Still Not Eligible: $($dg.StillNotEligible)" -ForegroundColor White |
| 115 | + Write-Host "│ ❌ Failed : $($dg.Failed)" -ForegroundColor White |
| 116 | + Write-Host "└───────────────────────────────────────────────────────────────────────────────┘" -ForegroundColor White |
| 117 | + } |
| 118 | +} |
0 commit comments