Update install-powershell.ps1

This commit is contained in:
Markus Fleschutz 2023-10-14 11:29:36 +02:00
parent fc2f04a133
commit 5f5acec687

View File

@ -74,7 +74,7 @@ if (-not $Destination) {
$Destination = $PSCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Destination) $Destination = $PSCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Destination)
if (-not $UseMSI) { if (-not $UseMSI) {
Write-Host "Installation destination path: $Destination" #Write-Host "Installation destination path: $Destination"
} else { } else {
if (-not $IsWinEnv) { if (-not $IsWinEnv) {
throw "-UseMSI is only supported on Windows" throw "-UseMSI is only supported on Windows"
@ -116,7 +116,7 @@ function Remove-Destination([string] $Destination) {
if ($DoNotOverwrite) { if ($DoNotOverwrite) {
throw "Destination folder '$Destination' already exist. Use a different path or omit '-DoNotOverwrite' to overwrite." throw "Destination folder '$Destination' already exist. Use a different path or omit '-DoNotOverwrite' to overwrite."
} }
Write-Host "Removing old installation at: $Destination" Write-Host "⏳ (2/2) Removing old installation at: $Destination"
if (Test-Path -Path "$Destination.old") { if (Test-Path -Path "$Destination.old") {
Remove-Item "$Destination.old" -Recurse -Force Remove-Item "$Destination.old" -Recurse -Force
} }
@ -381,7 +381,7 @@ try {
} }
$downloadURL = "https://github.com/PowerShell/PowerShell/releases/download/v${release}/${packageName}" $downloadURL = "https://github.com/PowerShell/PowerShell/releases/download/v${release}/${packageName}"
Write-Host "Downloading: $downloadURL" Write-Host "⏳ (1/2) Loading $downloadURL"
$packagePath = Join-Path -Path $tempDir -ChildPath $packageName $packagePath = Join-Path -Path $tempDir -ChildPath $packageName
if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") { if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") {
@ -508,10 +508,12 @@ try {
} }
if (-not $UseMSI) { if (-not $UseMSI) {
Write-Host "PowerShell has been installed at: $Destination" Write-Host "PowerShell has been installed at: $Destination" -noNewline
if ($Destination -eq $PSHOME) { if ($Destination -eq $PSHOME) {
Write-Host "Please restart pwsh" -ForegroundColor Magenta Write-Host " - Please restart pwsh now."
} } else {
Write-Host " "
}
} }
} finally { } finally {
# Restore original value # Restore original value