ContainerInfo/Get-NavContainerServerConfiguration.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
27
28
29
30
31
32
33
34
35
36
<#
 .Synopsis
  Retrieve the Server configuration from a NAV/BC Container as a powershell object
 .Description
  Returns all the settings of the middletier from a container.
 .Parameter containerName
  Name of the container for which you want to get the server configuration
 .Example
  Get-NavContainerServerConfiguration -ContainerName "MyContainer"
#>

Function Get-NavContainerServerConfiguration {
    Param (
        [Parameter(Mandatory=$true)]
        [String] $ContainerName
    )

    $ResultObjectArray = @()
    $config = Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock{
        Get-NAVServerConfiguration -ServerInstance $ServerInstance -AsXml
    }
    
    $Object = New-Object -TypeName PSObject -Property @{
        ContainerName = $ContainerName
    }

    $Config.configuration.appSettings.add | ForEach-Object{
        $Object | Add-Member -MemberType NoteProperty -Name $_.Key -Value $_.Value
    }

    $ResultObjectArray += $Object
    
    Write-Output $ResultObjectArray
}
Set-Alias -Name Get-BCContainerServerConfiguration -Value Get-NavContainerServerConfiguration
Export-ModuleMember -Function Get-NavContainerServerConfiguration -Alias Get-BCContainerServerConfiguration