feat(toolkit): use the folder picker for launcher path prompts

Move the fzf folder browser to Scripts/Private/Select-FolderPath.ps1 so
the launcher can use it too. Full tenant export root, tenant A and B
export folders and the report folder of the offline compare, the
earlier-export choice of the drift check and the report paths now open
the picker. It starts at the nearest existing folder, falls back to a
plain prompt without fzf and understands ~ and quotes.
This commit is contained in:
2026-11-24 13:12:12 +01:00
parent f2f200f904
commit 57917e9183
4 changed files with 110 additions and 80 deletions
+38 -37
View File
@@ -108,6 +108,7 @@ function Select-MenuItem
#endregion
$projectRoot = $PSScriptRoot
. (Join-Path $projectRoot "Scripts/Private/Select-FolderPath.ps1")
#region Tenant selection
function Get-DefaultSettingsPath
@@ -330,35 +331,34 @@ $commonParams = @{
# is assigned automatically, so entries can be added or moved without renumbering anything.
$menuDefs = @(
# Export / Import
"1. Export policies"
"2. Import policies"
"23. Full tenant export (all types + assignments, dated folder)"
"7. Export assignments to CSV/Markdown"
"5. Backup assignments"
"6. Restore assignments"
@{ Id = 1; Label = "Export policies" }
@{ Id = 2; Label = "Import policies" }
@{ Id = 23; Label = "Full tenant export (all types + assignments, dated folder)" }
@{ Id = 7; Label = "Export assignments to CSV/Markdown" }
@{ Id = 5; Label = "Backup assignments" }
@{ Id = 6; Label = "Restore assignments" }
# Bulk operations
"3. Bulk app assignment"
"4. Bulk assignment manager (policies)"
"8. Bulk rename policies"
"21. Bulk delete policies"
"24. Bulk scope tags (add / replace / remove / clean up)"
"9. Bulk device operations"
@{ Id = 3; Label = "Bulk app assignment" }
@{ Id = 4; Label = "Bulk assignment manager (policies)" }
@{ Id = 8; Label = "Bulk rename policies" }
@{ Id = 21; Label = "Bulk delete policies" }
@{ Id = 24; Label = "Bulk scope tags (add / replace / remove / clean up)" }
@{ Id = 9; Label = "Bulk device operations" }
# Baselines & compliance
"10. Deploy baseline"
"11. Deploy baseline (dry-run / WhatIf)"
"17. Deploy CIS M365 baseline"
"19. Document Conditional Access policies"
@{ Id = 10; Label = "Deploy baseline" }
@{ Id = 11; Label = "Deploy baseline (dry-run / WhatIf)" }
@{ Id = 17; Label = "Deploy CIS M365 baseline" }
@{ Id = 19; Label = "Document Conditional Access policies" }
# Reporting
"16. Generate reports"
"20. Export Entra role membership"
"22. Compare two tenant exports (offline)"
@{ Id = 16; Label = "Generate reports" }
@{ Id = 20; Label = "Export Entra role membership" }
@{ Id = 22; Label = "Compare two tenant exports (offline)" }
# Tenant & auth admin
"12. Initialize auth (one-time setup)"
"13. Refresh tenant names"
"18. Rotate app secret"
"14. Delete local tenant auth only"
"15. Delete tenant auth and app registration"
"0. Exit"
@{ Id = 12; Label = "Initialize auth (one-time setup)" }
@{ Id = 13; Label = "Refresh tenant names" }
@{ Id = 18; Label = "Rotate app secret" }
@{ Id = 14; Label = "Delete local tenant auth only" }
@{ Id = 15; Label = "Delete tenant auth and app registration" }
)
$menuIdByNumber = @{}
$menuItems = @()
@@ -482,18 +482,18 @@ while($true)
$exportPath = $null
if($dataSource -like "*fresh*")
{
$exportPath = Read-Host "Export path (where to save fresh data)"
$exportPath = Select-FolderPath -Prompt "Export path (where to save fresh data)"
if([string]::IsNullOrWhiteSpace($exportPath)) { Write-Host "Required." -ForegroundColor Red; continue }
$backupRoot = $exportPath
}
else
{
$backupRoot = Read-Host "Backup root path"
$backupRoot = Select-FolderPath -Prompt "Backup root path"
if([string]::IsNullOrWhiteSpace($backupRoot)) { Write-Host "Required." -ForegroundColor Red; continue }
if(-not (Test-Path $backupRoot)) { Write-Host "Path not found: $backupRoot" -ForegroundColor Red; continue }
}
$outputDir = Read-Host "Output directory for reports"
$outputDir = Select-FolderPath -Prompt "Output directory for reports"
if([string]::IsNullOrWhiteSpace($outputDir)) { Write-Host "Required." -ForegroundColor Red; continue }
$includeAssignments = $false
@@ -528,9 +528,8 @@ while($true)
{
$defaultRoot = Get-LauncherSetting -SettingsPath $settingsPath -Name "FullExportRoot"
if([string]::IsNullOrWhiteSpace($defaultRoot)) { $defaultRoot = Join-Path $HOME "Local/IntuneExports" }
$root = Read-Host "Export root folder (Enter = $defaultRoot)"
if([string]::IsNullOrWhiteSpace($root)) { $root = $defaultRoot }
$root = [IO.Path]::GetFullPath(($root.Trim().Trim('"',"'") -replace '^~', $HOME))
$root = Select-FolderPath -Prompt "Export root folder" -StartPath $defaultRoot -Default $defaultRoot
if(-not $root) { continue }
Set-LauncherSetting -SettingsPath $settingsPath -Name "FullExportRoot" -Value $root
$tenantLabel = if($currentTenant -and $currentTenant.TenantName) { $currentTenant.TenantName } else { $TenantId }
@@ -561,9 +560,10 @@ while($true)
{
$prevPath = if($prev) { $prev.FullName } else { $null }
$hint = if($prevPath) { "Enter = $($prev.Name)" } else { "path to an earlier export, Enter to skip" }
$ans = Read-Host "`nCompare with an earlier export to see drift? ($hint, n = skip)"
$ans = Read-Host "`nCompare with an earlier export to see drift? ($hint, n = skip, b = browse)"
if($ans -like 'n') { $prevPath = $null }
elseif(-not [string]::IsNullOrWhiteSpace($ans)) { $prevPath = [IO.Path]::GetFullPath(($ans.Trim().Trim('"',"'") -replace '^~', $HOME)) }
elseif($ans -like 'b') { $prevPath = Select-FolderPath -Prompt "Earlier export to compare with" -StartPath $root }
elseif(-not [string]::IsNullOrWhiteSpace($ans)) { $prevPath = ConvertTo-FullFolderPath $ans }
if($prevPath -and (Test-Path -LiteralPath $prevPath -PathType Container))
{
$prevName = Split-Path $prevPath -Leaf
@@ -590,21 +590,22 @@ while($true)
$sides = @()
foreach($side in "A","B")
{
$root = Read-Host "Export folder of tenant $side"
$browseStart = Get-LauncherSetting -SettingsPath $settingsPath -Name "FullExportRoot"
if([string]::IsNullOrWhiteSpace($browseStart)) { $browseStart = Join-Path $HOME "Local/IntuneExports" }
$root = Select-FolderPath -Prompt "Export folder of tenant $side" -StartPath $browseStart
if([string]::IsNullOrWhiteSpace($root)) { Write-Host "Required." -ForegroundColor Red; $sides = $null; break }
$root = [IO.Path]::GetFullPath(($root.Trim().Trim('"',"'") -replace '^~', $HOME))
if(-not (Test-Path -LiteralPath $root -PathType Container)) { Write-Host "Folder not found: $root" -ForegroundColor Red; $sides = $null; break }
$defaultLabel = Split-Path $root -Leaf
$label = Read-Host "Label for tenant $side (default: $defaultLabel)"
if([string]::IsNullOrWhiteSpace($label)) { $label = $defaultLabel }
$strip = Read-Host "Name prefix regex to strip for tenant $side, e.g. ^SSD\s*-\s* (Enter for none)"
$browseStart = Split-Path $root -Parent
$sides += ,@($root, $label, $strip)
}
if(-not $sides) { continue }
$outputDir = Read-Host "Output directory for the comparison report"
$outputDir = Select-FolderPath -Prompt "Output directory for the comparison report" -StartPath $browseStart
if([string]::IsNullOrWhiteSpace($outputDir)) { Write-Host "Required." -ForegroundColor Red; continue }
$outputDir = [IO.Path]::GetFullPath(($outputDir.Trim().Trim('"',"'") -replace '^~', $HOME))
$pyArgs = @(
(Join-Path $projectRoot "Scripts/Compare-Tenants.py"),