Public/Get-LocalPilotRecipe.ps1
|
function Get-LocalPilotRecipe { <# .SYNOPSIS Retrieves built-in or custom Machine-as-Code recipes for LocalPilot. .DESCRIPTION Returns a declarative workstation configuration recipe containing persona packages, Windows features, debloat rules, privacy settings, and performance tweaks. .PARAMETER Persona Predefined persona blueprint. Options: DevWorkstation, HomelabVM, GamingMinimal, FamilyClean. .PARAMETER Path Path to a custom JSON recipe file. .PARAMETER ExportTemplate Exports a clean JSON recipe template to file or console. .PARAMETER OutputPath Target file path when using -ExportTemplate. .EXAMPLE $recipe = Get-LocalPilotRecipe -Persona DevWorkstation .EXAMPLE Get-LocalPilotRecipe -ExportTemplate -OutputPath "C:\dotfiles\my-workstation.json" #> [CmdletBinding(DefaultParameterSetName = 'Persona')] param ( [Parameter(ParameterSetName = 'Persona', Position = 0)] [ValidateSet('DevWorkstation', 'HomelabVM', 'GamingMinimal', 'FamilyClean')] [string]$Persona = 'DevWorkstation', [Parameter(ParameterSetName = 'CustomFile', Mandatory = $true)] [string]$Path, [Parameter(ParameterSetName = 'Template')] [switch]$ExportTemplate, [Parameter(ParameterSetName = 'Template')] [string]$OutputPath ) if ($PSCmdlet.ParameterSetName -eq 'CustomFile') { if (-not (Test-Path -Path $Path)) { throw "Recipe file not found at '$Path'" } $raw = Get-Content -Path $Path -Raw -Encoding utf8 return ($raw | ConvertFrom-Json) } $recipes = @{ DevWorkstation = [PSCustomObject]@{ Name = 'DevWorkstation' Description = 'Power workstation for developers, cloud engineers, and IT pros.' Debloat = $true HardenPrivacy = $true ConfigurePerformance = $true WindowsFeatures = @('Microsoft-Windows-Subsystem-Linux', 'VirtualMachinePlatform') WingetPackages = @( 'Git.Git', 'Microsoft.PowerShell', 'Microsoft.VisualStudioCode', 'Microsoft.WindowsTerminal', '7zip.7zip', 'JanDeDobbeleer.OhMyPosh', 'Google.Chrome' ) PowerPlan = 'HighPerformance' Tweaks = [PSCustomObject]@{ DisableBingStartSearch = $true DisableLockScreenTips = $true ShowFileExtensions = $true ShowHiddenFiles = $true } } HomelabVM = [PSCustomObject]@{ Name = 'HomelabVM' Description = 'Streamlined, lightweight Windows image for hypervisor VMs and lab testing.' Debloat = $true HardenPrivacy = $true ConfigurePerformance = $true WindowsFeatures = @() WingetPackages = @( 'Microsoft.PowerShell', '7zip.7zip', 'Git.Git', 'Curl.Curl' ) PowerPlan = 'HighPerformance' Tweaks = [PSCustomObject]@{ DisableBingStartSearch = $true DisableLockScreenTips = $true ShowFileExtensions = $true ShowHiddenFiles = $true } } GamingMinimal = [PSCustomObject]@{ Name = 'GamingMinimal' Description = 'Stripped-down, maximum-performance gaming setup with low latency and zero bloat.' Debloat = $true HardenPrivacy = $true ConfigurePerformance = $true WindowsFeatures = @() WingetPackages = @( 'Valve.Steam', 'Discord.Discord', '7zip.7zip', 'OBSProject.OBSStudio', 'Spotify.Spotify' ) PowerPlan = 'HighPerformance' Tweaks = [PSCustomObject]@{ DisableBingStartSearch = $true DisableLockScreenTips = $true DisableGameDVR = $true ShowFileExtensions = $true } } FamilyClean = [PSCustomObject]@{ Name = 'FamilyClean' Description = 'Clean, safe, bloat-free configuration for family and non-technical user PCs.' Debloat = $true HardenPrivacy = $true ConfigurePerformance = $false WindowsFeatures = @() WingetPackages = @( 'Google.Chrome', 'Adobe.Acrobat.Reader.64-bit', '7zip.7zip', 'VideoLAN.VLC' ) PowerPlan = 'Balanced' Tweaks = [PSCustomObject]@{ DisableBingStartSearch = $true DisableLockScreenTips = $true ShowFileExtensions = $false } } } if ($ExportTemplate) { $template = $recipes['DevWorkstation'] $json = $template | ConvertTo-Json -Depth 5 if ($OutputPath) { $dir = Split-Path -Path $OutputPath -Parent if ($dir -and -not (Test-Path -Path $dir)) { New-Item -Path $dir -ItemType Directory -Force | Out-Null } $json | Set-Content -Path $OutputPath -Encoding utf8 Write-Host " [LocalPilot] Recipe template saved to '$OutputPath'" -ForegroundColor Green } return $json } return $recipes[$Persona] } |