Skip to content
Open
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
8 changes: 5 additions & 3 deletions PS7Bootstrap.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<#PSScriptInfo
.VERSION 1.0.1
.VERSION 1.0.2
.GUID 2d80b74b-905a-4d91-97af-35f0d3fe56e7
.AUTHOR Michael Niehaus
.COMPANYNAME
Expand Down Expand Up @@ -58,7 +58,9 @@ Write-Host "Minimum PowerShell version = $MinimumVersion"

# Install or upgrade as needed
if ($currentVersion -lt $MinimumVersion) {

# make sure current shell is elevated, which is required for the global .msi installation of pwsh
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
throw "Admin privileges required for global PS7 install. Please re-run elevated." }
Write-Host "Installing PowerShell LTS"
Invoke-Expression "& { $(Invoke-RestMethod https://aka.ms/install-powershell.ps1) } -UseMSI -Quiet"

Expand All @@ -73,6 +75,6 @@ if ($Script -ne "") {
& pwsh.exe -ExecutionPolicy bypass -File $Script
}
Catch {
Throw "Failed to start $PSCOMMANDPATH"
Throw "Failed to start $($Script) using pwsh.exe"
}
}