Private/Utilities/Get-AutomationUpdates.ps1
function Get-AutomationUpdates { Set-Variable -Name AutomationCurrentVersion -Value $($MyInvocation.MyCommand.ScriptBlock.Module.Version) -Scope Global if( -not [bool](Get-Variable AutomationUpdateNotice -Erroraction SilentlyContinue) ) { Set-Variable -Name AutomationUpdateNotice -Value $true -Scope Global } if( -not $Global:AutomationNewestVersion) { $Response = ((Invoke-WebRequest -Uri "https://www.powershellgallery.com/packages/JyskIT.Automation" -MaximumRedirection 0 -ErrorAction SilentlyContinue -SkipHttpErrorCheck).Headers.Location -split '/')[-1] Set-variable -Name AutomationNewestVersion -Value $($Response) -Scope Global } if($Global:AutomationNewestVersion -gt $Global:AutomationCurrentVersion) { if( $Global:AutomationUpdateNotice ) { Write-Host "New version available: $($Global:AutomationNewestVersion)" -BackgroundColor Green -ForegroundColor Black Write-Host "Please update the module..." -BackgroundColor Green -ForegroundColor Black Set-Variable -Name AutomationUpdateNotice -Value $false -Scope Global Pause Clear-Host } } } |