From 18fc5190d8ffcbf2c251e8c69da872474512c3c0 Mon Sep 17 00:00:00 2001 From: Tomas Kracmar Date: Tue, 14 Apr 2026 19:51:16 +0200 Subject: [PATCH] feat(launcher): add 'Refresh tenant names' menu option - Menu entry 13 re-queries Graph /organization for every saved tenant - Updates cached TenantName values in Settings.json - Refreshes the active tenant display in the menu header --- Scripts/Start-IntuneToolkit.ps1 | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Scripts/Start-IntuneToolkit.ps1 b/Scripts/Start-IntuneToolkit.ps1 index c3fcd6d..336151d 100644 --- a/Scripts/Start-IntuneToolkit.ps1 +++ b/Scripts/Start-IntuneToolkit.ps1 @@ -275,6 +275,7 @@ $commonParams = @{ } $menuItems = @( + "13. Refresh tenant names" "12. Initialize auth (one-time setup)" "11. Deploy baseline (dry-run / WhatIf)" "10. Deploy baseline" @@ -333,6 +334,7 @@ while($true) 10 { $script = "Scripts/Deploy-IntuneBaseline.ps1" } 11 { $script = "Scripts/Deploy-IntuneBaseline.ps1"; $commonParams.WhatIf = $true } 12 { $script = "Scripts/Initialize-IntuneAuth.ps1" } + 13 { $script = $null } default { continue } } @@ -350,6 +352,38 @@ while($true) 11 { $commonParams.WhatIf = $true } } + if($choiceNumber -eq 13) + { + Write-Host "`nRefreshing tenant names..." -ForegroundColor Cyan + $tenantsToRefresh = Get-SavedTenants -SettingsPath $settingsPath + $refreshed = 0 + $failed = 0 + foreach($t in $tenantsToRefresh) + { + Write-Host " Resolving $($t.TenantId) ..." -ForegroundColor DarkGray -NoNewline + $name = Resolve-TenantName -TenantId $t.TenantId -SettingsPath $settingsPath + if($name) + { + Update-TenantNameCache -SettingsPath $settingsPath -TenantId $t.TenantId -TenantName $name + Write-Host " -> $name" -ForegroundColor Green + $refreshed++ + if($t.TenantId -eq $TenantId) + { + $currentTenant = [PSCustomObject]@{ TenantId = $TenantId; TenantName = $name; Display = "$name ($TenantId)" } + } + } + else + { + Write-Host " -> FAILED" -ForegroundColor Red + $failed++ + } + } + Write-Host "`nRefresh complete. Success: $refreshed, Failed: $failed" -ForegroundColor Cyan + Write-Host "`nPress any key to return to the menu..." -ForegroundColor DarkGray + $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") + continue + } + $scriptPath = Join-Path $projectRoot $script if(-not (Test-Path $scriptPath)) {