Install-Powershell.ps1: Add parameter to use MSI installation (#10921)

This commit is contained in:
MJECloud
2019-10-30 13:02:12 -07:00
committed by Travis Plunk
parent 7b7fb0ef5e
commit 96e2a2e941
+34 -4
View File
@@ -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
}