Skip to content

Commit 9e2afc0

Browse files
authored
Improve progress handling and output overall
1 parent 53d6030 commit 9e2afc0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

EntraID/ConditionalAccess/Export-CAPolicies.ps1

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,22 +236,24 @@ if (-not $IncludeEmptyColumns) {
236236
$ProcessedCount = 0
237237
$OutputCount = 0
238238
#Get all service principals
239-
Write-Progress -Activity "`n Retrieving service principals..."
239+
Write-Host "[+] Retrieving service principals..."
240240
$ServicePrincipalsHash = Get-MgBetaServicePrincipal -All | Group-Object -Property AppId -AsHashTable
241-
Write-Progress -Activity "`n Retrieving named location..."
241+
Write-Host "[+] Retrieving named locations..."
242242
$NamedLocationHash = Get-MgBetaIdentityConditionalAccessNamedLocation -All | Group-Object -Property Id -AsHashTable
243243
Write-Host "Exporting CA policies report..." -ForegroundColor Cyan
244244

245245

246-
#Processing all CA polcies
247-
Get-MgBetaIdentityConditionalAccessPolicy -All | ForEach-Object {
246+
#Processing all CA policies
247+
$AllPolicies = Get-MgBetaIdentityConditionalAccessPolicy -All
248+
$total = $AllPolicies.Count
249+
$AllPolicies | ForEach-Object {
248250
$ProcessedCount++
249251
$CAName = $_.DisplayName
250252
$Description = $_.Description
251253
$CreationTime = $_.CreatedDateTime
252254
$LastModifiedTime = $_.ModifiedDateTime
253255
$State = $_.State
254-
Write-Progress -Activity "`n Processed CA policies count: $ProcessedCount "`n" Currently Processing: $CAName"
256+
Write-Progress -Activity "Exporting Conditional Access Policies" -Status "Processing: $CAName" -PercentComplete (($ProcessedCount / $total) * 100)
255257

256258
#Filter CA policies based on their State
257259
if ($ActiveCAPoliciesOnly.IsPresent -and $State -ne "Enabled") {

0 commit comments

Comments
 (0)