mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Install-Powershell.ps1: Add parameter to use MSI installation (#10921)
This commit is contained in:
@@ -38,6 +38,12 @@ param(
|
||||
[Parameter(ParameterSetName = "MSI")]
|
||||
[switch] $Quiet,
|
||||
|
||||
[Parameter(ParameterSetName = "MSI")]
|
||||
[switch] $AddExplorerContextMenu,
|
||||
|
||||
[Parameter(ParameterSetName = "MSI")]
|
||||
[switch] $EnablePSRemoting,
|
||||
|
||||
[Parameter()]
|
||||
[switch] $Preview
|
||||
)
|
||||
@@ -68,6 +74,14 @@ if (-not $UseMSI) {
|
||||
} else {
|
||||
if (-not $IsWinEnv) {
|
||||
throw "-UseMSI is only supported on Windows"
|
||||
} else {
|
||||
$MSIArguments = @()
|
||||
if($AddExplorerContextMenu) {
|
||||
$MSIArguments += "ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1"
|
||||
}
|
||||
if($EnablePSRemoting) {
|
||||
$MSIArguments += "ENABLE_PSREMOTING=1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,12 +314,20 @@ try {
|
||||
if ($IsWinEnv) {
|
||||
if ($UseMSI -and $Quiet) {
|
||||
Write-Verbose "Performing quiet install"
|
||||
$process = Start-Process msiexec -ArgumentList "/i", $packagePath, "/quiet" -Wait -PassThru
|
||||
$ArgumentList=@("/i", $packagePath, "/quiet")
|
||||
if($MSIArguments) {
|
||||
$ArgumentList+=$MSIArguments
|
||||
}
|
||||
$process = Start-Process msiexec -ArgumentList $ArgumentList -Wait -PassThru
|
||||
if ($process.exitcode -ne 0) {
|
||||
throw "Quiet install failed, please rerun install without -Quiet switch or ensure you have administrator rights"
|
||||
}
|
||||
} elseif ($UseMSI) {
|
||||
Start-Process $packagePath -Wait
|
||||
if($MSIArguments) {
|
||||
Start-Process $packagePath -ArgumentList $MSIArguments -Wait
|
||||
} else {
|
||||
Start-Process $packagePath -Wait
|
||||
}
|
||||
} else {
|
||||
Expand-ArchiveInternal -Path $packagePath -DestinationPath $contentPath
|
||||
}
|
||||
@@ -356,12 +378,20 @@ try {
|
||||
if ($IsWinEnv) {
|
||||
if ($UseMSI -and $Quiet) {
|
||||
Write-Verbose "Performing quiet install"
|
||||
$process = Start-Process msiexec -ArgumentList "/i", $packagePath, "/quiet" -Wait -PassThru
|
||||
$ArgumentList=@("/i", $packagePath, "/quiet")
|
||||
if($MSIArguments) {
|
||||
$ArgumentList+=$MSIArguments
|
||||
}
|
||||
$process = Start-Process msiexec -ArgumentList $ArgumentList -Wait -PassThru
|
||||
if ($process.exitcode -ne 0) {
|
||||
throw "Quiet install failed, please rerun install without -Quiet switch or ensure you have administrator rights"
|
||||
}
|
||||
} elseif ($UseMSI) {
|
||||
Start-Process $packagePath -Wait
|
||||
if($MSIArguments) {
|
||||
Start-Process $packagePath -ArgumentList $MSIArguments -Wait
|
||||
} else {
|
||||
Start-Process $packagePath -Wait
|
||||
}
|
||||
} else {
|
||||
Expand-ArchiveInternal -Path $packagePath -DestinationPath $contentPath
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user