Zum Inhalt springen
License Import and Service Restart for Multiple BC Instances

How-To Import License and Restart All Service Tiers

Daniel Gorski
Daniel Gorski 26. Januar 2022
2 Min. Lesezeit

If you are running multiple Instances of Microsoft Dynamics 365 Business Central Servers on one machine – here is a small script to update the license and restart them!


So our Environment has these three Instances:

ServerInstance : MicrosoftDynamicsNavServer$BC180
DisplayName   : Microsoft Dynamics 365 Business Central Server [BC180]
State         : Running
ServiceAccount: Administrator
Version       : 18.0.26213.26464
ServerInstance : MicrosoftDynamicsNavServer$BC180_2
DisplayName   : Microsoft Dynamics 365 Business Central Server [BC180_2]
ServerInstance : MicrosoftDynamicsNavServer$BC180_3
DisplayName   : Microsoft Dynamics 365 Business Central Server [BC180_3]

If you run this on powershell:

Get-Service | where-object {$_.ServiceName -like 'MicrosoftDynamicsNavServer*'} | Foreach-Object {
  $_.ServiceName
}

Returns:

MicrosoftDynamicsNavServer$BC180
MicrosoftDynamicsNavServer$BC180_2
MicrosoftDynamicsNavServer$BC180_3

Now split the string and get the 2nd value (Instance Name):

($\_.ServiceName -split "\\$")\[1\]

BC180
BC180_2
BC180_3

So let's put everything together:

  1. Import-Module of Nav.Management
  2. Get the Path or our License File
  3. Iterate through all Instances and Import the License into our NAV Server
  4. Restart it
Import-Module "C:\Program Files\Microsoft Dynamics 365 Business Central\180\Service\Microsoft.Dynamics.Nav.Management.psd1"
$license = (Get-ChildItem -Filter *.flf).FullName

Get-Service | where-object {$_.ServiceName -like 'MicrosoftDynamicsNavServer*'} | Foreach-Object {
    $serviceinstance = ($_.ServiceName -split "\$")[1]
    Import-NAVServerLicense -LicenseFile $license -ServerInstance $serviceinstance -Force
    Restart-NAVServerInstance -ServerInstance $serviceinstance -Force
}

Or just Start all Services which stopped:

Get-Service | where-object {($_.ServiceName -like 'MicrosoftDynamicsNavServer*') -and ($_.Status -eq "Stopped")} | Foreach-Object {
  $serviceinstance = ($_.ServiceName -split "\$")[1]
  Restart-NAVServerInstance -ServerInstance $serviceinstance -Force
}
beyondit
how-to
Business Central
License Import
PowerShell
Automation
Service Tiers
E-Invoicing-Formate UBL, CII, ZUGFeRD und Factur-X im Vergleich

UBL, CII, ZUGFeRD, Factur-X: Die E-Invoicing-Formate endlich verständlich erklärt

UBL, CII, ZUGFeRD oder Factur-X – diese E-Invoicing-Formate werden ständig verwechselt. Wir erklären den Unterschied zwischen reinen XML-Formaten und Hybridform

Weiter lesen: UBL, CII, ZUGFeRD, Factur-X: Die E-Invoicing-Formate endlich verständlich erklärt
Weiter lesen: UBL, CII, ZUGFeRD, Factur-X: Die E-Invoicing-Formate endlich verständlich erklärt
E-Invoicing formats UBL, CII, ZUGFeRD and Factur-X compared

UBL, CII, ZUGFeRD, Factur-X: E-Invoicing Formats Finally Explained

UBL, CII, ZUGFeRD or Factur-X – these e-invoicing formats get confused all the time. We break down the difference between pure XML formats and hybrid PDF-plus-X

Weiter lesen: UBL, CII, ZUGFeRD, Factur-X: E-Invoicing Formats Finally Explained
Weiter lesen: UBL, CII, ZUGFeRD, Factur-X: E-Invoicing Formats Finally Explained