Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions tools/install-powershell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ param(
[Parameter(ParameterSetName = "MSI")]
[switch] $Quiet,

[Parameter(ParameterSetName = "MSI")]
[switch] $AddExplorerContextMenu,

[Parameter(ParameterSetName = "MSI")]
[switch] $EnablePSRemoting,

[Parameter()]
[switch] $Preview
)
Expand Down Expand Up @@ -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"
}
}
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down