Functions/Get-BcVersion.ps1
<#
.Synopsis Returns the Business Central Version, VersionNumber, VersionFolder and ProductAbb. .DESCRIPTION Returns the Business Central Version, VersionNumber, VersionFolder and ProductAbb in an hashtable. Returns $false if NavVersion is not valid. Usefull to get the version name (example: nav2017) corresponding to the VersionFolder code (example: 100), or the other way around. .EXAMPLE $BcVersion = Get-BcVersion -BcVersion bc15 $BcVersion.Version # is "2017" $BcVersion.VersionFolder # is "100" $BcVersion.ProductAbb # is 'BC' .EXAMPLE $BcVersion = Get-BcVersion -VersionFolder '100' $BcVersion.Version # is "2017" $BcVersion.VersionFolder # is "100" $BcVersion.ProductAbb # is 'NAV' .EXAMPLE $BcVersion = Get-BcVersion -BcVersion 'nav2013r2' $BcVersion.Version # is "2013 R2" $BcVersion.VersionFolder # is "71" $BcVersion.ProductAbb # is 'NAV' .PARAMETER BcVersion The BcVersion, example: 'bc19', 'bc18', 'bc17', 'nav2017', 'nav2013 R2' .PARAMETER VersionFolder The Version Folder, example: '190', '180', '170', '100', '71' #> function Get-BcVersion { [CmdletBinding(DefaultParameterSetName="BcVersion")] [OutputType([hashtable])] Param ( [Parameter(Mandatory=$true, ParameterSetName = "BcVersion")] [String] $BcVersion, [Parameter(Mandatory=$true, ParameterSetName = "VersionFolder")] [String] $VersionFolder ) [hashtable] $Version = @{Version = ''; VersionNumber = ''; VersionFolder = ''; ProductAbb = '';} if ($BcVersion -eq "bc20" -or $VersionFolder -eq "200") { $Version.Version = 'bc20' $Version.VersionNumber = "20" $Version.VersionFolder = "200" $Version.ProductAbb = 'BC' } if ($BcVersion -eq "bc19" -or $VersionFolder -eq "190") { $Version.Version = 'bc19' $Version.VersionNumber = "19" $Version.VersionFolder = "190" $Version.ProductAbb = 'BC' } if ($BcVersion -eq "bc18" -or $VersionFolder -eq "180") { $Version.Version = 'bc18' $Version.VersionNumber = "18" $Version.VersionFolder = "180" $Version.ProductAbb = 'BC' } if ($BcVersion -eq "bc17" -or $VersionFolder -eq "170") { $Version.Version = 'bc17' $Version.VersionNumber = "17" $Version.VersionFolder = "170" $Version.ProductAbb = 'BC' } if ($BcVersion -eq "bc16" -or $VersionFolder -eq "160") { $Version.Version = 'bc16' $Version.VersionNumber = "16" $Version.VersionFolder = "160" $Version.ProductAbb = 'BC' } if ($BcVersion -eq "bc15" -or $VersionFolder -eq "150") { $Version.Version = 'bc15' $Version.VersionNumber = "15" $Version.VersionFolder = "150" $Version.ProductAbb = 'BC' } if ($BcVersion -eq "bc14" -or $VersionFolder -eq "140") { $Version.Version = 'bc14' $Version.VersionNumber = "14" $Version.VersionFolder = "140" $Version.ProductAbb = 'BC' } if ($BcVersion -eq "bc13" -or $VersionFolder -eq "130") { $Version.Version = 'bc13' $Version.VersionNumber = "13" $Version.VersionFolder = "130" $Version.ProductAbb = 'BC' } if ($BcVersion -eq "nav2018" -or $VersionFolder -eq "110") { $Version.Version = "nav2018" $Version.VersionNumber = "2018" $Version.VersionFolder = "110" $Version.ProductAbb = 'NAV' } if ($BcVersion -eq "nav2017" -or $VersionFolder -eq "100") { $Version.Version = "nav2017" $Version.VersionNumber = "2017" $Version.VersionFolder = "100" $Version.ProductAbb = 'NAV' } if ($BcVersion -eq "nav2016" -or $VersionFolder -eq "90") { $Version.Version = "nav2016" $Version.VersionNumber = "2016" $Version.VersionFolder = "90" $Version.ProductAbb = 'NAV' } if ($BcVersion -eq "nav2015" -or $VersionFolder -eq "80") { $Version.Version = "nav2015" $Version.VersionNumber = "2015" $Version.VersionFolder = "80" $Version.ProductAbb = 'NAV' } if ($BcVersion -like '*2013R2' -or $BcVersion -like '*2013 R2' -or $VersionFolder -eq "71") { $Version.Version = "nav2013R2" $Version.VersionNumber = "2013 R2" $Version.VersionFolder = "71" $Version.ProductAbb = 'NAV' } if(-not $Version.Version){ return $false } return $Version } Export-ModuleMember -Function Get-BcVersion |