CompanyHandling/Get-CompanyInNavContainer.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<#
 .Synopsis
  Get a list of companies in the database
 .Description
  Create a session to a Nav container and run Get-NavCompany
 .Parameter containerName
  Name of the container in which you want to get the companies
  .Parameter tenant
  Name of tenant you want to get the commpanies for in the container
 .Example
  Get-CompanyInNavContainer -containerName navserver
#>

function Get-CompanyInNavContainer {
    Param(
        [Parameter(Mandatory=$true)]
        [string]$containerName,
        [Parameter(Mandatory=$false)]
        [string]$tenant = "default"
    )

    Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($tenant)
        Get-NavCompany -ServerInstance NAV -Tenant $tenant
    } -ArgumentList $tenant
}
Export-ModuleMember -Function Get-CompanyInNavContainer