I am using powershell to run a few navcodeunits but I am getting credential errors because my environment has been setup with navuserpassword authentication. Is there a way to handle this without switching to windows credientials.
Here is the error:
Invoke-NAVCodeunit NAV -CodeunitId 37044411 -MethodName rdSetupWarehouseEmployeesForAllLocationsWithDefaultLocationFromPowershell -Argument "TESTFORLONGNAME,Detroit"
Invoke-NAVCodeunit : The server has rejected the client credentials.
+ CategoryInfo : NotSpecified: (0:Int32) [Invoke-NAVCodeunit], FaultException`1
+ FullyQualifiedErrorId : MicrosoftDynamicsNavServer$NAV,Microsoft.Dynamics.Nav.Management.Cmdlets.InvokeNavCodeunit
I don’t think it’s possible. You need to have the user under which you’re running the PowerShell script on NAV. You don’t need to switch to Windows authentication:
In your PowerShell script, first create the user in NAV with your Windows credentials (using New-NavServerUser) with the appropriate permissions. In this way you’ve A Windows user with the correct permissions in NAV. Then, run Invoke-NAVCodeunit.
Check this link
The suggestion on the link says: The solution was simply to create a new user (Windows authentication) and permission set for the Windows user running PowerShell. After creating this user I was able to run the codeunit. There is no need to create a separate NST handling Windows authentication.
Unfortunately in Dynamics 365, I am not seeing a way to create a windows user.
In my previous comment I’ve showed the solution that works for NAV 2018. What are you talking about?
How do you do this in Business Central inside of a Docker container?
Business Central inside of a Docker container is essentially Dynamics NAV in a Docker container.
I don't understand how the person on the Mibuso thread got a user with Windows credentials working with an NST (service tier) set to credential type NavUserPassword, but if it does work, you can do the same from the Navserver PowerShell Prompt (you'll have to import the NAV Admin Module). Alternately, the Nav Container Helper also has a function to create a new NAV user in the container called "New-NavContainerWindowsUser"
To see all the parameters associated with the New-NavContainerWindowsUser function, type the following command inside Nav Container Helper:
Get-Help New-NavContainerWindowsUser -Detailed
(It may ask you if you want to run Update-Help, and if it does, type in Y for Yes.)
This will show you all the parameters, and other information on using the parameters.
I hope this helps. If my response has answered your question, please verify by clicking Yes next to "Did this answer your question?"
Business Applications communities