I want to use the New-NAVServerUser Command (see: https://learn.microsoft.com/en-us/powershell/module/microsoft.dynamics.nav.management/new-navserveruser?view=businesscentral-ps-16) in a container to create a new Nav User. The Container has been build by PowerShell this way:
# Path to licence
$licenceFile = 'C:\pathToLicence\Licence.flf'
# Containername and NavImage
$containername = "NewContainer" # Name des Containers
$imagename = "mcr.microsoft.com/businesscentral/onprem:14.7.37609.0-de"
New-NavContainer -accept_eula -licenseFile $licenceFile -containerName $containername -imageName $imagename -doNotExportObjectsToText -includeCSide -TimeZoneId (Get-TimeZone).Id -shortcuts "Desktop" -alwaysPull -updateHosts -useBestContainerOS -accept_outdated
When im done, i try the following script to create a new NavUser:
[String]$ContiName = "NewContainer";
# Go into the Container to execute the script in it.
Invoke-ScriptInBCContainer -containerName $ContiName -scriptblock {
#Import Module to create Navuser
Import-Module "${env:ProgramFiles}\Microsoft Dynamics NAV\140\Service\NavAdminTool.ps1"
New-NavServerUser -WindowsAccount 'NEWCONTAINER\USER' -ServerInstance 'MicrosoftDynamicsNavServer$NAV'
}
As you can imagine, the Username of the Windows Account on the machine the container is running on is "User". So this wont work and this error occurs:
This is, because NEWCONTAINER/User already exists. Now I want to create a new Windows User in the container to use the New-NAVServerUser Command. Does anyone Know how it works? So the overall goal is to get a new NavUser in Table "User 2000000120" on Page "Users 9800" and the User should base on a Windows Account. Thanks for answers!
The Powershell Command I was looking for was "New-NavContainerWindowsUser" or outside the container: "New-LocalUser".