UI/_OnHomeWindowSourceInitialized.ps1

function _OnHomeWindowSourceInitialized {
    $HomeWindow_LoadingLabel.Visibility = 'Hidden'

    if ($STTSettings.FeatureSettings.SCCM) {
        # SCCM enabled
        $HomeWindow_SCCMDeploymentButton.IsEnabled = $true

        if (!($SCCMDevices)) {
            $HomeWindow_BannerButton.Visibility = 'Visible'
        }
        else {
            $HomeWindow_BannerButton.Visibility = 'Hidden'
        }
    }
    else {
        $HomeWindow_SCCMDeploymentButton.IsEnabled = $false

        $HomeWindow_BannerButton.Visibility = 'Hidden'
    }

    Write-Verbose 'Update Check'
    $UpdateCheck = _CheckForUpdate
    if ($UpdateCheck.Outdated) {
        $HomeWindow_UpdateStatusBarItem.Content = 'Update Found!'
        $MessageSplat = @{
            MessageText  = "An update was found.`nCurrent version: $($UpdateCheck.Current)`nNew version: $($UpdateCheck.Newest)`nDo you want to update now?`n`nRelease Notes: $($UpdateCheck.ReleaseNotes)"
            MessageIcon  = 'Asterisk'
            ButtonType   = 'YesNo'
            MessageTitle = 'Update Found'
        }
        $Answer = _ShowMessageBox @MessageSplat
        switch ($Answer) {
            Yes {
                Update-Module $ModuleName
                Write-Output 'Module Updated. Open a new powershell session to load the new version.'
                break
            }
            No {
                Update-Module $ModuleName
                Write-Output 'Module Updated. Open a new powershell session to load the new version.'
                break
            }
            Default {
            }
        }
    }

    $HomeWindow_AccountStatusBarItem.Content = "Running as: $UserName, $(if ($IsDomainAdmin){ 'Domain Admin' } elseif ($IsLocalAdmin){ 'Local Admin' } else { 'Regular User' })"
}