(view source code of airregtfcmd.ps as plain text)
<#.SYNOPSISSearch the online Icelandic aircraft registration database for an Icelandic aircraft registation and if found, return the aircraft manufacturer and model (tab-delimited).DESCRIPTIONRun this script with an aircraft registration as its only parameter (see examples section).The script will try to find the registration in the online Icelandic aircraft registry.If a match is found, the script will display a tab-delimited string with the registration and the manufacturer/model (<registration><tab><tab><manufacturer_and_model>).If the script was started by another PowerShell script, the calling PowerShell script may also read the manufacturer/model from the variable $Manufacturer, passed on by this script.If the script was started by a batch file, the calling batch file can use 'FOR /F' on this PowerShell script's screen output to find the manufacturer/model.Get-Help './AirRegPHCmd.ps1' -Examples will show 2 examples of this script being called by another script..PARAMETER RegistrationA valid Icelandic aircraft registration, i.e. TF-xxx (where each x is a single letter).PARAMETER QuietIgnore all errors and do not display any error messages; in case of errors, just terminate with return code 1.PARAMETER HelpShow the script's help screen.PARAMETER DebugShow some progress messages.OUTPUTSA tab-delimited string with <registration><tab><manufacturer_and_model>, and a variable $Model set to manufacturer AND model.EXAMPLE. ./AirRegTFmd.ps1 "TF-NPK"Will return tab-delimited string "TF-NPK<tab>Douglas C47A" and set variable $Model to "Douglas C47A".EXAMPLE"TF-NPK" | . ./AirRegTFCmd.ps1Will also return tab-delimited string "TF-NPK<tab>Douglas C47A" and set variable $Model to "Douglas C47A".EXAMPLECreate and run the following PowerShell script:===============================================================$Registration = 'TF-NPK' ; $Model = ''[void] ( . "$PSScriptRoot\AirRegTFCmd.ps1" -Registration $Registration )Write-Host ( "Registration : {0}`nModel : {1}" -f $Registration, $Model )===============================================================Besides setting variable $Model to "Douglas C47A", it will return:Registration : TF-NPKModel : Douglas C47A.EXAMPLECreate and run the following batch file:===============================================================REM Note that there should only be a TAB and nothing else between delims= and the doublequoteFOR /F "tokens=1-3 delims= " %%A IN ('powershell . ./AirRegTFCmd.ps1 TF-NPK') DO ( ECHO Registration : %%A ECHO Model : %%B)===============================================================It will return:Registration : TF-NPKModel : Douglas C47A.LINKScript written by Rob van der Woude:https://www.robvanderwoude.com/.LINKIcelandic Transport Authority online aircraft registry:https://www.icetra.is/aviation/aircraft/register/#>param (
[parameter( ValueFromPipeline )]
[ValidatePattern("(^\s*$|[\?/]|^TF-[A-Z]{3}$)")]
[string]$Registration,
[switch]$Quiet,
[switch]$Help
)$progver = "1.00"
$Registration = $Registration.ToUpper( )
$Manufacturer = ''
$Model = ''
[bool]$Debug = ( $PSBoundParameters.ContainsKey( 'Debug' ) )
function ShowHelp( $message = '' ) {
if ( !$Quiet ) {
if ( $errormessage ) {
Write-HostWrite-Host "Error: " -ForegroundColor Red -NoNewline
Write-Host $errormessage
} Write-HostWrite-Host ( "AirRegTFCmd.ps1, Version {0}" -f $progver )
Write-Host "Search online Icelandic aircraft registration database for a registation"
Write-HostWrite-Host "Usage: " -NoNewline
Write-Host ". ./AirRegTFCmd.ps1 [-Registration] TF-*** [-Quiet] [-Debug] [-Help]" -ForegroundColor White
Write-HostWrite-Host "Where: " -NoNewline
Write-Host "TF-*** " -NoNewline -ForegroundColor White
Write-Host "is a valid Icelandic aircraft registration, e.g. TF-NPK"
Write-Host " -Quiet " -NoNewline -ForegroundColor White
Write-Host "all errors are ignored and no error messages displayed"
Write-Host " -Debug " -NoNewline -ForegroundColor White
Write-Host "shows some progress messages"
Write-Host " -Help " -NoNewline -ForegroundColor White
Write-Host "shows this help screen"
Write-HostWrite-Host "Notes: This script uses the Icelandic aircraft registration database at:"
Write-Host " https://www.icetra.is/aviation/aircraft/register/" -ForegroundColor DarkGray
Write-Host " The result, if any, of the search is displayed as tab-delimited text:"
Write-Host " <registration><tab><manufacturer_and_model>"
Write-Host " Besides its screen output, this script will also set the `$Model"
Write-Host " variable with the database search result."
Write-Host " Run " -NoNewline
Write-Host "Get-Help `"./AirRegTFCmd.ps1`" -Examples " -NoNewline -ForegroundColor White
Write-Host "for some examples of"
Write-Host " `"nesting`" this script in other PowerShell or batch scripts."
Write-Host " Return code (`"ErrorLevel`") 1 in case of errors, otherwise 0."
Write-HostWrite-Host "Written by Rob van der Woude"
Write-Host "https://www.robvanderwoude.com"
} exit 1}if ( $Help -or $Registration -match "(^\s*$|^-|\?|/)" ) {
ShowHelp
exit 1}$dburl = 'https://www.icetra.is/aviation/aircraft/register/'
#$regurl = "https://www.icetra.is/aviation/aircraft/register?aq=$Registration"$pattern = ( '(?sm)<td class="letters"><a[^>]*>({0})</a></td>[^<]*<td class="serialno">[^<]*</td>[^<]*<td class="type">([^<]+)</td>' -f $Registration )
if ( $Debug ) {
$StopWatch = [System.Diagnostics.Stopwatch]::StartNew( )
Write-Host ( "Starting online search for {0} at {1}" -f $Registration, ( Get-Date ) )
}$ProgressPreference = 'SilentlyContinue'
$html = ( Invoke-WebRequest -Uri $dburl -Method 'Merge' ).Content
$ProgressPreference = 'Continue'
$Matches = ( $html | Select-String -Pattern $pattern -AllMatches ).Matches
if ( $Debug ) {
$StopWatch = [System.Diagnostics.Stopwatch]::StartNew( )
Write-Host ( "Ended online search for {0} at {1} with {2} matches found (elapsed time {3})" -f $Registration, ( Get-Date ), $Matches.Count, $StopWatch.Elapsed )
$StopWatch.Stop( )
}if ( $Matches.Count -eq 0 ) {
if ( !$Quiet ) {
Write-Host "Aircraft registration for $Registration not found"
}} else {
$Model = $Matches[0].Groups[2]
"{0}`t{1}" -f $Matches[0].Groups[1], $Model
}page last modified: 2025-10-11; loaded in 0.0110 seconds