Powershell to repeat the User Input when the result is not match to the pattern?


I need some assistance in modifying the script below to keep on prompting the users when the input is not the correct IP address format.

The script below will dump the result into Out-GridView for all DNS entries which contain the user input.

function Test-IPaddress {
    Param (
        [Parameter(Mandatory = $true,
                  ValueFromPipelineByPropertyName = $true,Position = 0)]
                  [ValidateScript({$_ -match [IPAddress]$_ })]


Try {
    $DNSServer = ''
    $IPAddress = $((Test-IPaddress -IPAddress (Read-Host -Prompt 'Input a valid IP address')).IPAddressToString)

    $zones = Get-DnsServerZone -ComputerName $DNSServer | Where-Object { !$_.IsReverseLookupZone -and $_.ZoneType -eq 'Primary' }
    $output = foreach ($zone in $zones) {
       Get-DnsServerResourceRecord -ComputerName $DNSServer -ZoneName $zone.ZoneName |
       Where-Object { $_.RecordData.Ipv4Address.IPAddressToString -contains $IPAddress } |
       Select-Object HostName, RecordType, Type, RecordData, Timestamp, TimeToLive, @{ n = 'Zone'; e = { $zone.ZoneName } }
    $output | Out-GridView -Title "IPAddress details for $IPAddress - $((Resolve-DnsName -Server $DNSServer -type A $IPaddress).Name) - Using DNS Server $($DNSServer)"
Catch {
    Add-Type -AssemblyName  System.Drawing,

    [System.Windows.Forms.MessageBox]::Show("Warning message for $IPAddress`n 
    $($PSItem.Exception.Message)" , 'Error', 'OK', 'Error')

Note: How can the Error message box be brought to the top (AlwaysOnTop) to bring up the user attention?

Thank you in advance.