Private/HomeWindow/_CheckForUpdate.ps1

function _CheckForUpdate {
    [CmdletBinding()]
    # [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification = "This runs automatically and doesn't need consent.")]
    param (
        [string]$Repository = 'PSGallery'
    )

    try {
        $RemoteVersion = Find-Module -Name $ModuleName -Repository $Repository
    }
    catch {
        $MessageSplat = @{
            MessageText  = "Unable to get module.`n$_"
            MessageIcon  = 'Hand'
            ButtonType   = 'OK'
            MessageTitle = 'Error'
        }
        _ShowMessageBox @MessageSplat
        $ModuleUpdateStatus = [PSCustomObject]@{
            Name     = $ModuleName
            Outdated = $false
        }
        return $ModuleUpdateStatus
    }

    $LocalVersion = Get-Module -Name $ModuleName

    try {
        $LocalVersion = ($LocalVersion | Where-Object Name -EQ $ModuleName).Version.ToString()
        $RepoVersion = ($RemoteVersion | Where-Object Name -EQ $ModuleName).Version.ToString()

        $ModuleUpdateStatus = [PSCustomObject]@{
            Name         = $ModuleName
            Outdated     = If ($LocalVersion -lt $RepoVersion) {
                $true
            }
            Else {
                $false
            }
            Current      = $LocalVersion
            Newest       = $RepoVersion
            ReleaseNotes = if (($Modules | Measure-Object).count -eq 1) {
                ($RemoteVersion | Where-Object Name -EQ $ModuleName).ReleaseNotes
            }
            else {
                ($RemoteVersion | Where-Object Name -EQ $ModuleName).ReleaseNotes.split("`n")[0]
            }
        }
    }
    catch {
        $MessageSplat = @{
            MessageText  = "Unable to check for updates: $Module.`n$_"
            MessageIcon  = 'Hand'
            ButtonType   = 'OK'
            MessageTitle = 'Error'
        }
        _ShowMessageBox @MessageSplat
        $ModuleUpdateStatus = [PSCustomObject]@{
            Name     = $ModuleName
            Outdated = $false
        }
    }

    return $ModuleUpdateStatus
}