Get-NAVTenant

Gets the tenants that are mounted against the specified Business Central Server instance.

Syntax

Get-NAVTenant
   [[-Tenant] <TenantId>]
   [-ServerInstance] <String>
   [-Force]
   [<CommonParameters>]
Get-NAVTenant
   [[-Tenant] <TenantId>]
   -ApplicationDatabaseServer <String>
   -ApplicationDatabaseCredentials <PSCredential>
   -ApplicationDatabaseName <String>
   [-Force]
   [<CommonParameters>]
Get-NAVTenant
   [[-Tenant] <TenantId>]
   -ApplicationDatabaseServer <String>
   -ApplicationDatabaseName <String>
   [-Force]
   [<CommonParameters>]
Get-NAVTenant
   [-Tenant] <TenantId>
   [-ServerInstance] <String>
   [-ForceRefresh]
   [-Force]
   [<CommonParameters>]

Description

Gets the tenants that are mounted against the specified Business Central Server instance. You can use the Mount-NAVTenant and Dismount-NAVTenant cmdlets to mount and dismount tenants.

Examples

EXAMPLE 1

Get-NAVTenant -ServerInstance 'BusinessCentral'

    ServerInstance                         : BusinessCentralServer$BusinessCentral
    TenantDatabaseId                       : TenantDB1
    State                                  : Mounted
    DetailedState                          :
    IsInExclusiveAccessMode                : False
    TenantDataVersion                      : 'Uninitialized'
    Id                                     : Tenant1
    AlternateId                            : {}
    AllowAppDatabaseWrite                  : True
    NasServicesEnabled                     : False
    RunNasWithAdminRights                  : False
    EncryptionProvider                     : LocalKeyFile
    AzureKeyVaultSettings                  :
    DefaultCompany                         :
    DefaultTimeZone                        : UTC
    ExchangeAuthenticationMetadataLocation : https://*.microsoft.com/,https://outlook.office365.com/,https://*.outlook.com/
    AadTenantId                            : common

This example gets the tenant information from the Business Central Server instance called 'BusinessCentral'. The output is a list of the tenant information about all mounted tenants, in this case two tenants. In this example, the server instance is configured to use the shared schema data model. If your instance is not running the shared schema data model, instead of the 'TenantDatabaseId', 'DatabaseName', 'DatabaseServer', and 'DatabaseUserName' are listed. ---------- EXAMPLE 2 ----------

Get-NAVTenant -ServerInstance 'BusinessCentral' -Tenant 'Tenant1' -ForceRefresh

ServerInstance                         : BusinessCentralServer$BusinessCentral
TenantDatabaseId                       : TenantDB1
State                                  : Operational
DetailedState                          :
IsInExclusiveAccessMode                : False
TenantDataVersion                      : 13.0.17887.0
Id                                     : Tenant1
AlternateId                            : {}
AllowAppDatabaseWrite                  : True
NasServicesEnabled                     : False
RunNasWithAdminRights                  : False
EncryptionProvider                     : LocalKeyFile
AzureKeyVaultSettings                  :
DefaultCompany                         :
DefaultTimeZone                        : UTC
ExchangeAuthenticationMetadataLocation :

https://.microsoft.com/,https://outlook.office365.com/,https://.outlook.com/ AadTenantId : common

This example gets the information about the tenant with the ID 'Tenant1' on Business Central Server instance 'BusinessCentral'. By setting the -ForceRefresh parameter, the 'State' and 'TenantDataversion' are refreshed to display the actual values (as compared to the first example).

Parameters

-ApplicationDatabaseCredentials

Specifies the user name and password of the login account that the Business Central Server instance uses to access the application database in SQL Server when using SQL Server Authentication.

This parameter is only relevant when you set with the ApplicationDatabaseServer and ApplicationDatabaseName parameters

Type:PSCredential
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ApplicationDatabaseName

Specifies the name of the application database that is used by the tenant database. This parameter is only relevant if the Business Central Server instance is configured for multitenancy.

This parameter, together with the ApplicationDatabaseServer parameter, enables you to dismount a tenant from a Business Central Server instance without having a running connection to the Business Central Server instance.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ApplicationDatabaseServer

Specifies the SQL Server name and instance, such as MyServer\MyInstance, that hosts the application database that is used with the tenant database.

This parameter, together with the ApplicationDatabaseName parameter, enables you to get the tenants that are mounted on a Business Central Server instance without having a running connection to the Business Central Server instance.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Force

Forces the command to run without asking for user confirmation.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ForceRefresh

Specifies to update a tenant's state and data version based, in part, on the data version of the tenant database that contains the tenant. By default, the data retrieved by the Get-NAVTenant is not necessarily up to date with the tenant database. This can happen, for example, after a Business Central Server instance restart. In this case, the 'State' would be 'Mounted', even if its actual state is 'Operational', and the 'TenantDataVersion' would be 'Uninitialized'. By setting the -ForceRefresh parameter, the server instance reads the data version of the tenant database from the database itself, and the tenant's state and data version are recalculated. Note: Running operations, such as sync, mount and dismount, on a specific tenant always ensures that tenant settings are up-to-date with the tenant database.

Type:SwitchParameter
Position:Named
Default value:False
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ServerInstance

Specifies the name of a Business Central Server instance, for example, BC or myinstance. You can specify either the full name of an instance, such as MicrosoftDynamicsNavServer$myinstance or the short name such as myinstance.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Tenant

Specifies the ID of the specific tenant that you want to get information about, such as Tenant1.

If you do not set the Tenant parameter, the Get-NAVTenant cmdlet returns all tenants that are mounted against the Business Central Server instance.

When using Get-NAVTenant through a connection to a Business Central Server instance, if the specified tenant ID is not found, then an error occurs. When using Get-NAVTenant through a connection to the application database, if the specified tenant ID is not found, then all mounted tenants are returned in the results.

Type:TenantId
Aliases:Id
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Inputs

System.String

You can pipe the ServerInstance as a string to this cmdlet.

Outputs

Microsoft.Dynamics.Nav.Types.NavTenantSettings

Returns a Microsoft.Dynamics.Nav.Types.NavTenantSettings object for each tenant. The following information is returned:

ServerInstance
TenantDatabaseId
State
DetailedState
IsInExclusiveAccessMode
TenantDataVersion (see notes)
Id
AlternateId
AlternateId
AllowAppDatabaseWrite
NasServicesEnabled
RunNasWithAdminRights
EncryptionProvider
DefaultCompany
DefaultTimeZone ExchangeAuthenticationMetadataLocation

Notes

The Tenant Data Version indicates the version of the tenant data. When and how the version is assigned can be explained by the following upgrade flow:

  • When an application is created, it is assigned an Application Version.
  • When a tenant database is upgraded, the Application Version is transferred to the tenant database.
  • When data upgrade is executed on the tenant data. the Application Version is transferred to the Tenant Database Version field.
  • When the upgrade process is completed, the tenant database will have the same version as the application (schema is synchronized) and the tenant data is the same as the application (tenant data has been upgraded).