mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-02-04 15:00:09 +00:00
Delete-WPFTweaksPowershell7 (#3825)
* Delete WPFTweaksPowershell7 from tweaks.json Removed WPFTweaksPowershell7 configuration for Windows Terminal. * Delete functions/public/Invoke-WPFTweakPS7.ps1
This commit is contained in:
@@ -1970,20 +1970,6 @@
|
|||||||
],
|
],
|
||||||
"link": "https://winutil.christitus.com/dev/tweaks/essential-tweaks/endtaskontaskbar"
|
"link": "https://winutil.christitus.com/dev/tweaks/essential-tweaks/endtaskontaskbar"
|
||||||
},
|
},
|
||||||
"WPFTweaksPowershell7": {
|
|
||||||
"Content": "Change Windows Terminal default: PowerShell 5 -> PowerShell 7",
|
|
||||||
"Description": "This will edit the config file of the Windows Terminal replacing PowerShell 5 with PowerShell 7 and installing PS7 if necessary",
|
|
||||||
"category": "z__Advanced Tweaks - CAUTION",
|
|
||||||
"panel": "1",
|
|
||||||
"Order": "a022_",
|
|
||||||
"InvokeScript": [
|
|
||||||
"Invoke-WPFTweakPS7 -action \"PS7\""
|
|
||||||
],
|
|
||||||
"UndoScript": [
|
|
||||||
"Invoke-WPFTweakPS7 -action \"PS5\""
|
|
||||||
],
|
|
||||||
"link": "https://winutil.christitus.com/dev/tweaks/essential-tweaks/powershell7"
|
|
||||||
},
|
|
||||||
"WPFTweaksPowershell7Tele": {
|
"WPFTweaksPowershell7Tele": {
|
||||||
"Content": "Disable Powershell 7 Telemetry",
|
"Content": "Disable Powershell 7 Telemetry",
|
||||||
"Description": "This will create an Environment Variable called 'POWERSHELL_TELEMETRY_OPTOUT' with a value of '1' which will tell Powershell 7 to not send Telemetry Data.",
|
"Description": "This will create an Environment Variable called 'POWERSHELL_TELEMETRY_OPTOUT' with a value of '1' which will tell Powershell 7 to not send Telemetry Data.",
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
function Invoke-WPFTweakPS7{
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
This will edit the config file of the Windows Terminal Replacing the Powershell 5 to Powershell 7 and install Powershell 7 if necessary
|
|
||||||
.PARAMETER action
|
|
||||||
PS7: Configures Powershell 7 to be the default Terminal
|
|
||||||
PS5: Configures Powershell 5 to be the default Terminal
|
|
||||||
#>
|
|
||||||
param (
|
|
||||||
[ValidateSet("PS7", "PS5")]
|
|
||||||
[string]$action
|
|
||||||
)
|
|
||||||
|
|
||||||
switch ($action) {
|
|
||||||
"PS7"{
|
|
||||||
if (Test-Path -Path "$env:ProgramFiles\PowerShell\7") {
|
|
||||||
Write-Host "Powershell 7 is already installed."
|
|
||||||
} else {
|
|
||||||
Write-Host "Installing Powershell 7..."
|
|
||||||
Install-WinUtilProgramWinget -Action Install -Programs @("Microsoft.PowerShell")
|
|
||||||
}
|
|
||||||
$targetTerminalName = "PowerShell"
|
|
||||||
}
|
|
||||||
"PS5"{
|
|
||||||
$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"
|
|
||||||
if (-not (Test-Path -Path $settingsPath)) {
|
|
||||||
Write-Host "Windows Terminal Settings file not found at $settingsPath"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Settings file found."
|
|
||||||
$settingsContent = Get-Content -Path $settingsPath | ConvertFrom-Json
|
|
||||||
$ps7Profile = $settingsContent.profiles.list | Where-Object { $_.name -eq $targetTerminalName }
|
|
||||||
if ($ps7Profile) {
|
|
||||||
$settingsContent.defaultProfile = $ps7Profile.guid
|
|
||||||
$updatedSettings = $settingsContent | ConvertTo-Json -Depth 100
|
|
||||||
Set-Content -Path $settingsPath -Value $updatedSettings
|
|
||||||
Write-Host "Default profile updated to " -NoNewline
|
|
||||||
Write-Host "$targetTerminalName " -ForegroundColor White -NoNewline
|
|
||||||
Write-Host "using the name attribute."
|
|
||||||
} else {
|
|
||||||
Write-Host "No PowerShell 7 profile found in Windows Terminal settings using the name attribute."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user