Module/BusinessCentral/Get-BCSTenantPerServerInstance.ps1
<#
.SYNOPSIS Get a list of tenants mounted on a Business Central Server Instance .DESCRIPTION Get a list of tenants mounted on a Business Central Server Instance .PARAMETER serverInstance Specifies the Business Central Server Instance to collect tenants from. .EXAMPLE Get-BCSTenantPerServerInstance -ServerInstance "MyServerInstance" .NOTES Author: Mathias Stjernfelt Website: http://www.brightcom.se #> function Get-BCSTenantPerServerInstance { Param ( [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)] [string]$serverInstance ) begin {} process { #Import-BCSDynamicsNavModules -ServerInstance $serverInstance $tenants = Get-NAVAppTenant -ServerInstance $serverInstance $Hash = [PSCustomObject]@(); foreach ($tenant in $tenants) { $item = New-Object PSObject $item | Add-Member -type NoteProperty -Name 'Id' -Value $tenant.Id; $item | Add-Member -type NoteProperty -Name 'ServerInstance' -Value $serverInstance; $item | Add-Member -type NoteProperty -Name 'DatabaseName' -Value $tenant.DatabaseName $item | Add-Member -type NoteProperty -Name 'DatabaseServer' -Value $tenant.DatabaseServer $item | Add-Member -type NoteProperty -Name 'State' -Value $tenant.State $item | Add-Member -type NoteProperty -Name 'TenantDataVersion' -Value $tenant.TenantDataVersion $item | Add-Member -type NoteProperty -Name 'AlternateId' -Value $tenant.ConcatenatedAlternateId $Hash += $item; } $Hash } end { } } Export-ModuleMember -Function Get-BCSTenantPerServerInstance |