Remove-NAVTenant

DO NOT USE: This cmdlet is for internal use only. It can’t be used for Business Central on-premises tenants. For information about managing on-premises tenants, see https://go.microsoft.com/fwlink/?linkid=2153727.

Syntax

Remove-NAVTenant
      [-ServerInstance] <String>
      [-Tenant] <TenantId>
      [-ForceImmediateRemoval]
      [-Force]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

Use the Remove-NAVTenant cmdlet to permanently delete a tenant and all its company and associated global data from the tenant database. This operation is immediate and cannot be undone.

The tenant must be mounted on a multitenant Business Central Server instance and the tenant database that it belongs to must be a shared schema database.

There are two ways to delete the tenant and its data:

  • If you don't use the -ForceImmediateRemoval parameter, the deletion is performed by a scheduled system task in task scheduler. The time of day that the task actually runs and deletes the tenant and its data is determined by the Business Central Server instance settings: TaskSchedulerSystemTaskStartTime and TaskSchedulerSystemTaskEndTime. Before the system tasks runs, the tenant state is 'SoftDeleted'. While the system task is running, the state is 'Deleting'. If the Business Central Server instance crashes while running the task, the task will be automatically rescheduled after a server instance mounts the tenant again.
  • If you use the -ForceImmediateRemoval switch parameter, the deletion starts immediately, without using task scheduler. If the server instance crashes while being deleted, the tenant should be manually removed by using Remove-NAVTenant again.

Whichever way you choose, as soon as you run the cmdlet, the tenant can no longer be accessed by client sessions. Any current sessions are lost. The tenant will remain mounted before, during, and after deletion. After a successful deletion, its state changes to 'Deleted'. A record of the tenant remains in the database until you dismount the tenant.

Examples

EXAMPLE 1

Remove-NAVTenant -ServerInstance NavServer -Tenant TenantA

This example uses server instance 'NavServer' to delete tenant 'TenantA'. Whether it will be deleted synchronously or through a scheduled task depends on the UseIncrementalCompanyDelete setting of the server instance.

EXAMPLE 2

Remove-NAVTenant -ServerInstance NavServer -Tenant TenantA -ForceImmediateRemoval
Dismount-NAVTenant -ServerInstance NavServer -Tenant TenantA

This example uses server instance 'NavServer' to delete tenant 'TenantA' immediately. The cmdlet will return after completely deleting the tenant. The Dismount-NAVTenant will delete the record of the tenant from the database.

EXAMPLE 3

Remove-NAVTenant -ServerInstance NavServer -Tenant TenantA -Async -ForceImmediateRemoval

This example uses server instance 'NavServer' to delete tenant 'TenantA' immediately. The cmdlet will return immediately, while the tenant is deleted in the background.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

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

-Force

Forces the command to run without asking for user confirmation.

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

-ForceImmediateRemoval

Specifies to delete the tenant, its companies, and global data immediately; instead of using a scheduled system task.

Type:SwitchParameter
Position:Named
Default value:False
Required:False
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 tenant that you want to remove. This tenant must be mounted on the server instance.

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

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

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

Inputs

System.String

By value and by property name: ServerInstance

Microsoft.Dynamics.Nav.Types.TenantId

By property name: Tenant

System.Management.Automation.SwitchParameter

By property name: ForceImmediateRemoval