Fix Windows 10 installation Appx commands error when pwsh.exe installed

Issue PowerShell/PowerShell#19031 still exists on Windows 10 and still not be fixed
This commit is contained in:
1552980358 2024-04-07 20:09:55 +08:00
parent 7da3a914a7
commit dbb4a085b0
No known key found for this signature in database
GPG Key ID: ECB2C291260654AE

View File

@ -38,6 +38,10 @@ function Get-InstalledDependencyVersion {
}
}
Function Check-Windows11 {
RETURN (Get-ComputerInfo | Select-Object -expand OsName) -match 11
}
Function Test-CommandExist {
Param ($Command)
$OldPreference = $ErrorActionPreference
@ -53,10 +57,9 @@ Function Finish {
Start-Process "wsa://com.android.vending"
}
If (Test-CommandExist pwsh.exe) {
If (Check-Windows11 -And Test-CommandExist pwsh.exe) {
$pwsh = "pwsh.exe"
}
Else {
} Else {
$pwsh = "powershell.exe"
}