Share via


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

Default (Default)

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.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Force

Forces the command to run without asking for user confirmation.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ForceImmediateRemoval

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

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments: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.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

-Tenant

Specifies the ID of the tenant that you want to remove. This tenant must be mounted on the server instance.

Parameter properties

Type:TenantId
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Id

Parameter sets

(All)
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-WhatIf

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

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