mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-16 01:40:35 -06:00
Handle Computers without Windows Terminal (eg Win10)
This commit is contained in:
parent
46cb89bb4f
commit
e262af617d
@ -25,9 +25,18 @@ function Invoke-WPFTweakPS7{
|
|||||||
$targetTerminalName = "Windows PowerShell"
|
$targetTerminalName = "Windows PowerShell"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# Check if the Windows Terminal is installed and return if not (Prerequisite for the following code)
|
||||||
|
if (-not (Get-Command "wt" -ErrorAction SilentlyContinue)){
|
||||||
|
Write-Host "Windows Terminal not installed. Skipping Terminal preference"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
# Check if the Windows Terminal settings.json file exists and return if not (Prereqisite for the following code)
|
||||||
$settingsPath = "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json"
|
$settingsPath = "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json"
|
||||||
if (Test-Path -Path $settingsPath) {
|
if (-not (Test-Path -Path $settingsPath)){
|
||||||
|
Write-Host "Windows Terminal Settings file not found at $settingsPath"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "Settings file found."
|
Write-Host "Settings file found."
|
||||||
$settingsContent = Get-Content -Path $settingsPath | ConvertFrom-Json
|
$settingsContent = Get-Content -Path $settingsPath | ConvertFrom-Json
|
||||||
$ps7Profile = $settingsContent.profiles.list | Where-Object { $_.name -eq $targetTerminalName }
|
$ps7Profile = $settingsContent.profiles.list | Where-Object { $_.name -eq $targetTerminalName }
|
||||||
@ -35,12 +44,10 @@ function Invoke-WPFTweakPS7{
|
|||||||
$settingsContent.defaultProfile = $ps7Profile.guid
|
$settingsContent.defaultProfile = $ps7Profile.guid
|
||||||
$updatedSettings = $settingsContent | ConvertTo-Json -Depth 100
|
$updatedSettings = $settingsContent | ConvertTo-Json -Depth 100
|
||||||
Set-Content -Path $settingsPath -Value $updatedSettings
|
Set-Content -Path $settingsPath -Value $updatedSettings
|
||||||
Write-Host "Default profile updated to $targetTerminalName using the name attribute."
|
Write-Host "Default profile updated to " -NoNewline
|
||||||
|
Write-Host "$targetTerminalName " -ForegroundColor White -NoNewline
|
||||||
|
Write-Host "using the name attribute."
|
||||||
} else {
|
} else {
|
||||||
Write-Host "No PowerShell 7 profile found in Windows Terminal settings using the name attribute."
|
Write-Host "No PowerShell 7 profile found in Windows Terminal settings using the name attribute."
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Write-Host "Settings file not found at $settingsPath"
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user