@@ -368,8 +368,8 @@ function Set-ProfileEnvironment ([hashtable]$Variables) {
368
368
369
369
ForEach ($Variable in $Variables.GetEnumerator ()) {
370
370
Write-Host - ForegroundColor White " Setting Environment Variable: " - NoNewline
371
- Write-Host - ForegroundColor Magenta " $ ( $Variable.Name ) " .PadRight(100 ).Substring(0 , ($NameLen +2 )) - NoNewline
372
- Write-Host " = $ ( $Variable.Value ) : " .PadRight(200 ).Substring(0 , ($ValLen + 2 )) - NoNewline
371
+ Write-Host - ForegroundColor Magenta " $ ( $Variable.Name ) " .PadRight(100 ).Substring(0 , ($NameLen + 2 )) - NoNewline
372
+ Write-Host " = $ ( $Variable.Value ) : " .PadRight(200 ).Substring(0 , ($ValLen + 2 )) - NoNewline
373
373
# Set Environment Variable
374
374
[System.Environment ]::SetEnvironmentVariable($Variable.Name , $Variable.Value , " Machine" )
375
375
Write-Host - ForegroundColor Green " done ✅"
@@ -391,5 +391,35 @@ function Initialize-OhMyPosh {
391
391
}
392
392
}
393
393
394
+ function Update-PowerShellCore {
395
+ $UpdateCheck = [pscustomobject ]@ {
396
+ Current = [version ]$PSVersionTable.PSVersion | Select-Object Major, Minor, Build;
397
+ Latest = [version ](Invoke-RestMethod - Uri " https://aka.ms/pwsh-buildinfo-stable" | Select-Object - ExpandProperty ReleaseTag | % { $_ -replace " v" }) | Select-Object Major, Minor, Build
398
+ }
399
+ $CurrentSemantic = ($UpdateCheck.Current.psobject.properties | ForEach-Object { $_.Value }) -join " ."
400
+ $LatestSemantic = ($UpdateCheck.Latest.psobject.properties | ForEach-Object { $_.Value }) -join " ."
401
+ $VersionSummary = " [ current: $ ( $CurrentSemantic ) latest: $ ( $LatestSemantic ) ]"
402
+
403
+ $NoUpdate = if (
404
+ $UpdateCheck.Current.Major -eq $UpdateCheck.Latest.Major -and
405
+ $UpdateCheck.Current.Minor -eq $UpdateCheck.Latest.Minor -and
406
+ $UpdateCheck.Current.Build -eq $UpdateCheck.Latest.Build
407
+ ) { $true }else { $false }
408
+ if ($NoUpdate ) {
409
+ Write-Host " PowerShell is up to date $VersionSummary "
410
+ }
411
+ else {
412
+ Write-Host " PowerShell needs to be updated $VersionSummary "
413
+ if (! (Get-Command - Name pwsh - ErrorAction SilentlyContinue)) {
414
+ winget install -- id Microsoft.PowerShell -- exact
415
+ }
416
+ else {
417
+ Write-Host - ForegroundColor White " Run " - NoNewline
418
+ Write-Host - ForegroundColor Yellow " winget install --id Microsoft.PowerShell --exact"
419
+ EXIT
420
+ }
421
+ }
422
+ }
423
+
394
424
395
425
Export-ModuleMember *-*
0 commit comments