Testing/Get-ContainerCompanyToTest.ps1
<# .synopsis Determines company in NAV/BC environment to be used for testing .description Determines company in NAV/BC environment to be used for testing .parameter ContainerName Container to be used. Can be provided in the settings.json .example $companyName = Get-ContainerCompanyToTest -ContainerName "test" #> function Get-ContainerCompanyToTest { param( # Container to use [Parameter(Mandatory = $false)] [string] $ContainerName = (Get-ContainerFromLaunchJson) ) [version]$BCFallPlatform = '15.0.0.0' $platform = Get-PlatformFromContainer -ContainerName $ContainerName if ($platform -ge $BCFallPlatform) { $Companies = (New-WebServiceProxy ('http://{0}:7047/BC/WS/SystemService?tenant=default' -f (Get-BcContainerIpAddress $ContainerName)) -Credential (Get-CredentialFromEnvironmentJson)).Companies() } else { $Companies = (New-WebServiceProxy ('http://{0}:7047/NAV/WS/SystemService' -f (Get-BcContainerIpAddress $ContainerName)) -Credential (Get-CredentialFromEnvironmentJson)).Companies() } # there is a blank company in the Danish database - don't ask, I don't know if ((Get-BcContainerCountry $ContainerName) -eq 'dk') { $CompanyName = $Companies.Item(1) } else { if ($null -eq $Companies.Count) { $CompanyName = $Companies } else { if ($Companies.Contains('CRONUS USA, Inc.')) { $CompanyName = 'CRONUS USA, Inc.' } else { $CompanyName = $Companies.Item(0) } } } $CompanyName } |