Created
April 12, 2017 13:36
-
-
Save dfranciscus/d88f0488beb7b16ff4cffd90dcfcd797 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
requires -Modules PSReleaseTools | |
<# | |
.SYNOPSIS | |
Compares local PowerShell version to Github latest release, installs using installpkg | |
#> | |
function Install-PowerShellonMac { | |
[CmdletBinding()] | |
param( | |
) | |
begin | |
{ | |
if ($IsOSX -eq $False) | |
{ | |
Write-Error -Message 'This function only runs on OS X' | |
break | |
} | |
} | |
process | |
{ | |
# Compare local PS and latest release | |
$CompareVersion = Get-PSReleaseCurrent | Where-Object {$_.Version -ne $_.LocalVersion} | Select-Object Version,LocalVersion | |
# If local version different that latest prompt user to install | |
if ($CompareVersion) | |
{ | |
Write-Output "$CompareVersion" | |
Read-Host "Press Enter to install latest PowerShell release or CTL + C to exit" | |
##Download PS and install using installpkg | |
$FileName = Get-PSReleaseAsset -Family MacOS | Select-Object FileName -ExpandProperty FileName | |
Get-PSReleaseAsset -Family MacOS | Save-PSReleaseAsset | |
sudo installpkg $FileName | |
} | |
#If local PS and latest release are same break | |
elseif (!$CompareVersion) | |
{ | |
Write-Output 'Your local version is the same as latest release' | |
break | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment