web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

How to invoke-navcodunit with navuserpassword

(0) ShareShare
ReportReport
Posted on by

Hi

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

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: How to invoke-navcodunit with navuserpassword

    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.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,237 Super User 2025 Season 2 on at
    RE: How to invoke-navcodunit with navuserpassword

    Check this link

    forum.mibuso.com/.../invoke-navcodeunit-the-server-has-rejected-the-client-credentials

  • Community Member Profile Picture
    on at
    RE: How to invoke-navcodunit with navuserpassword

    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.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: How to invoke-navcodunit with navuserpassword

    In my previous comment I’ve showed the solution that works for NAV 2018. What are you talking about?

  • Community Member Profile Picture
    on at
    RE: How to invoke-navcodunit with navuserpassword

    How do you do this in Business Central inside of a Docker container?

  • Suggested answer
    AJAnsari Profile Picture
    5,754 on at
    RE: How to invoke-navcodunit with navuserpassword

    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?"

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Saurav.Dhyani Profile Picture

Saurav.Dhyani 2 Super User 2025 Season 2

#1
Alexander Ermakov Profile Picture

Alexander Ermakov 2

#3
RK-25090803-0 Profile Picture

RK-25090803-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans