Last active
April 7, 2021 09:28
-
-
Save fatihtatoglu/28477fdcfda549fae5f1e3403c9faa4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$currentVersion = $PSVersionTable.PSVersion.Major | |
if ($currentVersion -ge 5) { | |
Write-Host "PowerShell is updated." | |
return | |
} | |
$url = "https://raw.githubusercontent.com/jborean93/ansible-windows/master/scripts/Upgrade-PowerShell.ps1" | |
$file = "$env:temp\Upgrade-PowerShell.ps1" | |
(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file) | |
Write-Host "Update script is downloaded." | |
$currentPolicy = Get-ExecutionPolicy -List | Where-Object Scope -eq "LocalMachine" | Select-Object ExecutionPolicy | |
if ($currentPolicy -ne "Unrestricted") { | |
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force | |
} | |
&$file -Version 5.1 -Verbose | |
Set-ExecutionPolicy -ExecutionPolicy $currentPolicy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment