Skip to main content

Insert SUPER User

The script imports the Microsoft.Dynamics.Nav.Management.dll module, which provides the cmdlets that are used to manage users and tenants.

info

Before running the script please fill out the variables

  • $ServerInstance is the name of the server instance on which the user should be created.
  • $WindowsAccount is the windows account of the user that will be added.
  • $Tenant is an optional parameter, if you want to create the user in a specific tenant, otherwise leave it blank.
  • $ProfileId is the profile Id of the user. The script is using the SUPER profile id by default, you can change it according to your requirement.
  • $NSTFolderPath is the path to the NAV Administration Shell Tools folder.

It's worth mentioning that the script should be run on the same machine as the Business Central Server Instance or the server instance should be reachable using the specified name.

The script checks whether the $Tenant variable is empty or not, if it's empty the script will use New-NAVServerUser cmdlet to create a new user with the WindowsAccount and ProfileId specified in the script and the -ServerInstance parameter, which specifies the server instance where the user will be created.

If $Tenant is not empty, the script will use New-NAVServerUser cmdlet with an additional -Tenant parameter which specifies the tenant in which the user will be created.

#-------------------------------PRE STEP------------------------------- 
$ServerInstance = ""
$WindowsAccount = ""
$Tenant = ""
$ProfileId = "SUPER"
$NSTFolderPath = "";
#-------------------------------DO NOT EDIT UNDER THIS LINE-------------------------------
Import-Module (Join-Path $NSTFolderPath "Microsoft.Dynamics.Nav.Management.dll");

$NewUserParams = @{
ServerInstance = $ServerInstance
WindowsAccount = $WindowsAccount
ProfileId = $ProfileId
}

if ($Tenant) {
$NewUserParams.Tenant = $Tenant
}

New-NAVServerUser @NewUserParams