(view source code of airregfcmd.ps as plain text)
<#.SYNOPSISSearch a downloaded French Agence Nationale des Titres Sécurisés aircraft registry database for a French aircraft registation and if found, return the aircraft manufacturer and model (tab-delimited).DESCRIPTIONFirst, create a subdirectory 'F' in this script's parent folder.Next, download the Agence Nationale des Titres Sécurisés aircraft registry database (see links section, use link marked 'Données du registre' on the website), move the file export.csv to the 'F' folder.Now run this script with a French aircraft registration as its only parameter (see examples section).The script will first look for the specified registration code in column 1 of the export.csv file.If a match is found, the manufacturer and model are found in columns 2 and 3.The script will display a tab-delimited string with the registration, the manufacturer and the aircraft model (<registration><tab><manufacturer><tab><model>).If the script was started by another PowerShell script, the calling PowerShell script may also read the manufacturer and model from the variables $Manufacturer and $Model, 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 and model.Get-Help './AirRegFCmd.ps1' -Examples will show 2 examples of this script being called by another script..PARAMETER RegistrationA valid French aircraft registration, e.g. F-AZXN.PARAMETER QuietIgnore all errors and do not display any error messages; in case of errors, just terminate with return code 1..PARAMETER VersionShow this script's version number; if combined with -Verbose show full script path, version number and last/modified/release date.PARAMETER CheckDBIf the required local database can be found, returns True and exit code 0; if not, returns False and exit code 1..PARAMETER HelpShow the script's help screen.PARAMETER DebugShow some progress messages.OUTPUTSIf a match is found: a tab-delimited string with <registration><tab><manufacturer_and_model>, and if -NoBreak switch is used: variables $Manufacturer set to aircraft manufacturer $Model set to aircraft modelIf no match is found: False.EXAMPLE. ./AirRegFCmd.ps1 F-AZXNWill return tab-delimited string "F-AZXN<tab>THE BOEING COMPANY<tab>STEARMAN A 75/N1", and set variables $Manufacturer to "THE BOEING COMPANY" and $Model to "STEARMAN A 75/N1".EXAMPLE"F-AZXN" | . ./AirRegFCmd.ps1Will also return tab-delimited string "F-AZXN<tab>THE BOEING COMPANY<tab>STEARMAN A 75/N1", and set variables $Manufacturer to "THE BOEING COMPANY" and $Model to "STEARMAN A 75/N1".EXAMPLE. ./AirRegFCmd.ps1 "F-AZXN" -DebugThis will return:Start searching F-AZXN in export.csv file at <date> <time>F-AZXN THE BOEING COMPANY STEARMAN A 75/N1Finished at <date> <time> (elapsed time <time elapsed>).EXAMPLECreate and run the following PowerShell script:===============================================================$Registration = 'F-AZXN' ; $Manufacturer = '' ; $Model = ''[void] ( . "$PSScriptRoot\AirRegFCmd.ps1" -Registration $Registration )Write-Host ( "Registration : {0}`nManufacturer : {1}`nModel : {2}" -f $Registration, $Manufacturer, $Model )===============================================================Besides setting variables $Manufacturer to "THE BOEING COMPANY" and $Model to "STEARMAN A 75/N1", it will return:Registration : F-AZXNManufacturer : THE BOEING COMPANYModel : STEARMAN A 75/N1.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 . ./AirRegFCmd.ps1 F-AZXN') DO ( ECHO Registration : %%A ECHO Manufacturer : %%B ECHO Model : %%C)===============================================================It will return:Registration : F-AZXNManufacturer : THE BOEING COMPANYModel : STEARMAN A 75/N1.LINKScript written by Rob van der Woude:https://www.robvanderwoude.com/.LINKAgence Nationale des Titres Sécurisés aircraft registry database:https://immat.aviation-civile.gouv.fr/immat/servlet/aeronef_liste.html.LINKCapture -Debug parameter by mklement0 on StackOverflow.com:https://stackoverflow.com/a/48643616#>param (
[parameter( ValueFromPipeline )]
[ValidatePattern("(^\s*$|[\?/]|^-|^F-[A-Z]{4}$)")]
[string]$Registration,
[switch]$CheckDB,
[switch]$Version,
[switch]$Quiet,
[switch]$Help
)$progver = "1.00"
$Registration = $Registration.ToUpper( )
$Manufacturer = ''
$Model = ''
[bool]$Debug = ( $PSBoundParameters.ContainsKey( 'Debug' ) )
[bool]$Verbose = ( $PSBoundParameters.ContainsKey( 'Verbose' ) )
if ( $Version ) {
if ( $Verbose ) {
$lastmod = ( [System.IO.File]::GetLastWriteTime( $PSCommandPath ) )
if ( $lastmod.ToString( "h.mm" ) -eq $progver ) {
"`"{0}`", Version {1}, release date {2}" -f $PSCommandPath, $progver, $lastmod.ToString( "yyyy-MM-dd" )
} else {
# if last modified time is not equal to program version, the script has been tampered with"`"{0}`", Version {1}, last modified date {2}" -f $PSCommandPath, $progver, $lastmod.ToString( "yyyy-MM-dd" )
}} else {
$progver } exit 0}if ( $Help -or [string]::IsNullOrWhiteSpace( $Registration ) -or ( $Registration -match "[/\?]" ) ) {
Clear-HostWrite-Host ( "`"{0}`", Version {1}" -f $PSCommandPath, $progver ) -NoNewline
$lastmod = ( [System.IO.File]::GetLastWriteTime( $PSCommandPath ) )
if ( $lastmod.ToString( "h.mm" ) -eq $progver ) {
Write-Host ", release date " -NoNewline
} else {
# if last modified time is not equal to program version, the script has been tampered withWrite-Host ", last modified date " -NoNewline
}Write-Host $lastmod.ToString( "yyyy-MM-dd" )
Write-HostGet-Help $PSCommandPath -Full
exit -1
}$dbfolder = ( Join-Path -Path $PSScriptRoot -ChildPath 'F' )
$dbfile = ( Join-Path -Path $dbfolder -ChildPath 'export.csv' )
if ( $CheckDB ) {
if ( Test-Path -Path $dbfile -PathType 'Leaf' ) {
[bool]$true
exit 0} else {
[bool]$false
exit 1 }}if ( Test-Path -Path $dbfile -PathType 'Leaf' ) {
if ( $Debug ) {
$StopWatch = [system.diagnostics.stopwatch]::StartNew( )
Write-Host ( "Start searching {0} in export.csv file at {1}" -f $Registration, ( Get-Date ) )
}$pattern = '^{0};[^\n\r]+' -f $Registration
$record = ( ( Get-Content -Path $dbfile ) -match $pattern )
if ( $record ) {
if ( $record.Split( ';' ).Count -gt 2 ) {
$Manufacturer = $record.Split( ';' )[1]
$Model = $record.Split( ';' )[2]
} }"{0}`t{1}`t{2}" -f $Registration, $Manufacturer, $Model | Out-String
if ( $Debug ) {
Write-Host ( "Finished at {0} (elapsed time {1})`n`n" -f ( Get-Date ), $StopWatch.Elapsed )
$StopWatch.Stop( )
}} else {
if ( $Quiet ) {
if ( $Debug ) {
Write-Host ( "Downloaded French Agence Nationale des Titres Sécurisés aircraft registry database file `"{0}`" not found" -f $dbfile )
} exit 1} else {
$message = "No downloaded French Agence Nationale des Titres Sécurisés aircraft registry database was found.`n`nDo you want to open the download webpage for the database now?"
$title = 'No Database Found'
$buttons = 'YesNo'
Add-Type -AssemblyName System.Windows.Forms
$answer = [System.Windows.Forms.MessageBox]::Show( $message, $title, $buttons )
if ( $answer -eq "Yes" ) {
$url = 'https://immat.aviation-civile.gouv.fr/immat/servlet/aeronef_liste.html'
Start-Process $url
} else {
ShowHelp( 'No downloaded French Agence Nationale des Titres Sécurisés aircraft registry database found, please download it and try again' )
} }}page last modified: 2025-10-11; loaded in 0.0135 seconds