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) { Set-variable -Name AutomationNewestVersion -Value $((Find-Module JyskIT.Automation).Version +1) -Scope Global } if($Global:AutomationNewestVersion -gt $Global:AutomationCurrentVersion) { if( $Global:AutomationUpdateNotice ) { Write-Host "Should only get here if notice has not been shown." -BackgroundColor Green -ForegroundColor Black 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 } } } |