From 1c12ff67f1056f3c5b508e254d107b797259aaf3 Mon Sep 17 00:00:00 2001 From: Maurice Jennen Date: Mon, 28 Oct 2019 10:33:30 +0100 Subject: [PATCH] Add Parameter for MSI Installation --- tools/install-powershell.ps1 | 38 ++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/tools/install-powershell.ps1 b/tools/install-powershell.ps1 index dab91b1b948..239ac47eeb0 100644 --- a/tools/install-powershell.ps1 +++ b/tools/install-powershell.ps1 @@ -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 }