Skip to content

Instantly share code, notes, and snippets.

@kilasuit
Last active August 2, 2019 23:44
Show Gist options
  • Save kilasuit/7ce30e04c7809aa5084d404d6d6d3bc5 to your computer and use it in GitHub Desktop.
Save kilasuit/7ce30e04c7809aa5084d404d6d6d3bc5 to your computer and use it in GitHub Desktop.
Showing a slightly safer way to install PowerShell instead of using IEX though still brings the same similar problems as IEX does
$wr = invoke-webrequest https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1
$sbuilder = [System.Text.StringBuilder]::new()
$sbuilder.AppendLine('function Install-ps {'}
$sbuilder.AppendLine($wr.content)
$sbuilder.AppendLine('}')
$sbuilder.AppendLine('')
$sbuilder.AppendLine('Install-ps -UseMSI -Preview') #Replace this with whatever switches you want to run instead from the ones available in the above script
$nsb = [Scriptblock]::Create($sbuilder.ToString())
. $nsb
@RobTain
Copy link

RobTain commented Aug 2, 2019

Error Line 4 -> Replace } with )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment