ContainerInfo/Get-NavContainerNavVersion.ps1

123456789101112131415161718192021222324252627282930

<#
.Synopsis
Get the version of NAV in a Nav container or a Nav container image
.Description
Returns the version of NAV in the format major.minor.build.release-country
.Parameter containerOrImageName
Name of the container or container image for which you want to get the version
.Example
Get-NavContainerNavVersion -containerOrImageName navserver
.Example
Get-NavContainerNavVersion -containerOrImageName microsoft/dynamics-nav:2017
#>functionGet-NavContainerNavVersion{[CmdletBinding()]Param([Parameter(Mandatory=$true)][string]$containerOrImageName)

Process{$inspect=dockerinspect$containerOrImageName|ConvertFrom-Jsonif($inspect.Config.Labels.psobject.Properties.Match('nav').Count-eq0){throw"Container $containerOrImageName is not a NAV container"}return"$($inspect.Config.Labels.version)-$($inspect.Config.Labels.country)"}}Export-ModuleMember-functionGet-NavContainerNavVersion