File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 Scan every subscription for Sonrai’s “Powerful Permissions in Azure.”
44
55. DESCRIPTION
6- - Connects using device code .
6+ - Connects using the normal interactive Windows sign-in experience (WAM) .
77 - Gathers your user’s role assignments per subscription.
88 - Tests each high-risk permission from the six-part Sonrai blog.
99 - Exports findings to CSV and writes colored console messages.
1414 - PowerShell 7+ (for colored output)
1515#>
1616
17- # 1. Authenticate
18- Write-Host " → Authenticating to Azure (Device Code)…" - ForegroundColor Cyan
19- Connect-AzAccount - UseDeviceAuthentication | Out-Null
17+ # 1. Authenticate using normal interactive sign-in (WAM on Windows)
18+ # Device-code authentication is intentionally not used.
19+ Write-Host " → Authenticating to Azure (interactive sign-in)..." - ForegroundColor Cyan
20+
21+ # Apply WAM only to this PowerShell process. This avoids changing the user's
22+ # persistent Az configuration and supports Conditional Access and MFA.
23+ if (Get-Command Update-AzConfig - ErrorAction SilentlyContinue) {
24+ Update-AzConfig - EnableLoginByWam $true - Scope Process | Out-Null
25+ }
26+
27+ Connect-AzAccount | Out-Null
2028
2129# 2. Identify current user
2230$currentUpn = (Get-AzContext ).Account.Id
You can’t perform that action at this time.
0 commit comments