Skip to main content Link Search Menu Expand Document (external link) Copy Copied

Business Central Powershell

Table of contents

  1. Modules Management
    1. Import Modules
  2. Used Variables
  3. Extensions Management
    1. Get all extensions list
    2. Publish extension
    3. Install extension
    4. Uninstall extension
    5. Uninstall all extensions at once
    6. Unpublish extensions
  4. Users Management
    1. Add a new Windows Account user
  5. License Management
    1. Import a license
  6. Web Server Instance Management
    1. Get web server instances
    2. Add a new web server instance
  7. Objects Exporting
    1. Export all objects from NAV Database to text file
    2. Export filtered objects
    3. Exports all objects and split into single-object files

Modules Management

Import Modules

Import-Module “C:\Program Files\Microsoft Dynamics 365 Business Central\140\Service\NAVAdminTool.ps1” -force

Import-Module “C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\140\RoleTailored Client\NAVModelTools.ps1” -force

Used Variables

$serverInstance = “PT_BC_CU2”

$extensionName = “Extension1”

$extensionVersion = “”

Extensions Management

Get all extensions list

Get-NAVAppInfo -ServerInstance -Tenant

Skip the tenant parameter to see all tenant extensions.

Get-NAVAppInfo -ServerInstance $serverInstance

Publish extension

Publish-NAVApp -ServerInstance -Path

Publish-NAVApp -ServerInstance $serverInstance -Path 'C:\Temp\'

Install extension

Install-NAVApp -ServerInstance -Name -Version

Install-NAVApp -ServerInstance $serverInstance -Name $extensionName -Version $extensionVersion

Uninstall extension

Uninstall-NAVApp -ServerInstance -Name -Version

Uninstall-NAVApp -ServerInstance $serverInstance -Name $extensionName -Version $extensionVersion

Uninstall all extensions at once

Get-NAVAppInfo -ServerInstance $serverInstance -Tenant default | % { Uninstall-NAVApp -ServerInstance $serverInstance -Name $_.Name -Version $_.Version } 

Unpublish extensions

Unpublish-NAVApp -ServerInstance -Name -Version

Unpublish-NAVApp -ServerInstance $serverInstance -Name $extensionName -Version $extensionVersion 

Users Management

Add a new Windows Account user

New-NavServerUser -WindowsAccount -ServerInstance New-NavServerUserPermissionSet -WindowsAccount -ServerInstance -PermissionSetId

New-NavServerUser -WindowsAccount 'domain.local\ricardo' -ServerInstance $serverInstance
New-NavServerUserPermissionSet -WindowsAccount 'domain.local\ricardo' -ServerInstance $serverInstance -PermissionSetId SUPER

License Management

Import a license

Imports a license file into a Business Central database

Import-NAVServerLicense -LicenseData ([Byte[]]$(Get-Content -Path "" -Encoding Byte))

Import-NAVServerLicense $serverInstance -LicenseData ([Byte[]]$(Get-Content -Path "$licenseFilePath" -Encoding Byte))

Web Server Instance Management

Get web server instances


Add a new web server instance

New-NAVWebServerInstance -WebServerInstance -Server -ServerInstance

  • Change WebServerInstance to the name that you want to give the virtual directory for the web server instance. This name will become part of the URL for the Microsoft Dynamics BC Web client application, for example, http://MyWebServer:8080/WebServerInstance/WebClient.
  • Change BCServer to the name of the computer that is running the Microsoft Dynamics BC Server to which you want to connect (ex. localhost)
  • Change ServerInstance to the name of the instance on the Microsoft Dynamics BC Server.
New-NAVWebServerInstance -WebServerInstance $newWebServerInstanceName -Server $BCServer -ServerInstance $serverInstance
New-NAVWebServerInstance -WebServerInstance bc-w1-15 -Server localhost -ServerInstance bc-w1-15

Objects Exporting

Export all objects from NAV Database to text file

Export-NAVApplicationObject "" -DatabaseServer -ExportTxtSkipUnlicensed

Example: Exports all objects from NAV2015AP-APP-TEST to NAV2015-All-Objects.txt

Export-NAVApplicationObject NAV2015AP-APP-TEST “E:\NAV2015-Objects\All-Objs\NAV2015-All-Objects.txt" -DatabaseServer MYP-RPAIVA\SQL2017 -ExportTxtSkipUnlicensed

Export filtered objects

Export-NAVApplicationObject "" -Filter '' -DatabaseServer -ExportTxtSkipUnlicensed

Example: Exports codeunits 80..84 from the NAV2015AP-APP-TEST to COD80-84.txt

Export-NAVApplicationObject NAV2015AP-APP-TEST “E:\NAV2015-Objects\All-Objs\NAV2015-All-Objects.txt" -Filter 'Type=Codeunit;Id=80..84' -DatabaseServer MYP-RPAIVA\SQL2017 -ExportTxtSkipUnlicensed

Exports all objects and split into single-object files

Export-NAVApplicationObject “" -Filter '' -DatabaseServer -DatabaseName -ExportTxtSkipUnlicensed | Split-NAVApplicationObjectFile -Destination ""

Example: Exports all objects and split V2015AP-APP-TEST* to Splitted-Objs folder

Export-NAVApplicationObject "E:\NAV2015-Objects\All-Objs\NAV2015-All-Objects.txt" -DatabaseServer MYP-RPAIVA\SQL2017 -DatabaseName NAV2015AP-APP-TEST -ExportTxtSkipUnlicensed | Split-NAVApplicationObjectFile -Destination "E:\NAV2015-Objects\Splitted-Objs"