if(Test-Path-Path"$env:ProgramFiles\PowerShell\7"){Write-Host"PowerShell 7 is already installed."}else{Write-Host"Installing PowerShell 7..."wingetinstall--idMicrosoft.PowerShell--silent}$targetTerminalName="PowerShell"if(-not(Get-Command"wt"-ErrorActionSilentlyContinue)){Write-Host"Windows Terminal not installed. Exiting..."exit}$settingsPath="$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json"if(-not(Test-Path-Path$settingsPath)){Write-Host"Windows Terminal settings.json not found."exit}$settingsContent=Get-Content-Path$settingsPath|ConvertFrom-Json$ps7Profile=$settingsContent.profiles.list|Where-Object{$_.name-eq$targetTerminalName}if($ps7Profile){$settingsContent.defaultProfile=$ps7Profile.guid$settingsContent|ConvertTo-Json-Depth100|Set-Content-Path$settingsPathWrite-Host"Default profile set to PowerShell 7"}else{Write-Host"No PowerShell 7 profile found."}
$targetTerminalName="Windows PowerShell"if(-not(Get-Command"wt"-ErrorActionSilentlyContinue)){Write-Host"Windows Terminal not installed. Exiting..."exit}$settingsPath="$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json"if(-not(Test-Path-Path$settingsPath)){Write-Host"Windows Terminal settings.json not found."exit}$settingsContent=Get-Content-Path$settingsPath|ConvertFrom-Json$ps5Profile=$settingsContent.profiles.list|Where-Object{$_.name-eq$targetTerminalName}if($ps5Profile){$settingsContent.defaultProfile=$ps5Profile.guid$settingsContent|ConvertTo-Json-Depth100|Set-Content-Path$settingsPathWrite-Host"Default profile reverted to PowerShell 5"}else{Write-Host"No Windows PowerShell profile found."}