Private/PartnerMenu/Start-PartnerMenuDomainInformation.ps1

function Start-PartnerMenuDomainInformation() {
    param(
        [Parameter()]
        $DomainName
    )

    if (!$DomainName -and !$Global:DomainName) {
        Get-PartnerMenuHeader -SectionString "Domain name information"

        $Global:DomainName = Read-Host "Enter a domain name: "
        if ($Global:DomainName -notmatch '^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$') {
            Write-Error "Invalid domain name: $($Global:DomainName)"
            $Global:DomainName = $null
            Read-Host "Press any key to continue.."
            Start-PartnerMenuDomainInformation
        }
    }
    Clear-Host

    Get-PartnerMenuHeader -SectionString "($($Global:DomainName)) - Domain name information"

    Write-Host "[1] Validate SPF-record."
    Write-Host "[2] Validate Microsoft 365 records."
    Write-Host "[3] Back."
    Write-Host ""
    $SelectedOption = Read-Host "Please select an option [1-3] "

    switch ($SelectedOption) {
        "1" {
            try {
                Confirm-SPF -DomainName $Global:DomainName
            }
            catch {
                Write-Error "Failed validate SPF records: $_"
            }
            Read-Host "Press any key to continue.."
            Start-PartnerMenuDomainInformation -DomainName $Global:DomainName
        }
        "2" {
            try {
                Confirm-M365Records -DomainName $Global:DomainName
            }
            catch {
                Write-Error "Failed to validate Microsoft 365 records: $_"
            }
            Read-Host "Press any key to continue.."
            Start-PartnerMenuDomainInformation -DomainName $Global:DomainName
        }
        "3" { 
            $Global:DomainName = $null
            Start-PartnerMenu
        }
        Default {
            $Global:DomainName = $null
            Start-PartnerMenu
        }
    }

}