diff --git a/PS7Bootstrap.ps1 b/PS7Bootstrap.ps1 index 902a95b..076fd3e 100644 --- a/PS7Bootstrap.ps1 +++ b/PS7Bootstrap.ps1 @@ -1,5 +1,5 @@ <#PSScriptInfo -.VERSION 1.0.1 +.VERSION 1.0.2 .GUID 2d80b74b-905a-4d91-97af-35f0d3fe56e7 .AUTHOR Michael Niehaus .COMPANYNAME @@ -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" @@ -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" } }