Using PowerShell to configure Dynamics NAV Services

Using PowerShell to configure Dynamics NAV Services

  • Comments 2

 

The Microsoft All-In-One Code Site has a new NAV code sample. This time it demonstrates using PowerShell to

  1. Get a list of NAV 2009 Services, either on the local machine or on a remote machine, and
  2. Start and stop a service

The sample also includes a small bit of XML, so that you can use it to update CustomSettings.config.

With quite small amounts of code, by combining PowerShell and XML, you can control a NAV Service - either locally or remotely - without the need for Notepad, opening services, finding CustomSettings.config in Windows Explorer, etc.

You can download the sample or just browse the sample code from this link:

 Download Microsoft Dynamics NAV APPLICATION: CSDynamicsPowerShellAdmin

 

This is sample code only. It is specifically designed not to be a full app so it has lots of scope for adding functionality. Hopefully it can be useful as a starting point or inspiration for developing own tools.

 

After downloading the code sample and building it in Visual Studio 2010, then running "CSDynamicsPowerShellAdmin.exe" (run it as Administrator), this is what it looks like when running it from my test machine:

 

And this is what it can do:

  • Click "Get NAV Services" to list local NAV Services. It finds Services where pathname like \"%Dynamics.Nav%\".
  • Enter the name of another machine and then click "Get NAV Services" to get a list of NAV Services on that machine. Assuming that you are administrator on that machine.
  • Select a NAV Service in the list to see Service properties like Name, Account, Status etc.
  • Click "Get Config" to read parts of CustomSettings.config for the selected NAV Service.
  • Overwrite values, then click "Update Config" to update CustomSettings.config.
  • Start and Stop the selected NAV Service. This only works if you are running it with elevated privileges.

 

 

Lars Lohndorf-Larsen

Dynamics NAV Support EMEA

 

Leave a Comment
  • Please add 5 and 5 and type the answer here:
  • Post
  • On free time, I'm currently working on a winform to apply hotfixes to the various client/servers (currently we have to manually copy/paste the content of the folders). Here there are more info about it.

    www.mibuso.com/.../viewtopic.php

    I think it would it be an idea to implement such a functionality in the powershelladmin!

  • Good idea! I could certainly use a tool like that to automate it when needing to test something with this or that build. The Powershell sample should have the answers to a few of the questions: It's retrieving a list of services, filtered on the service executable name (pathname like "%Dynamics.Nav%"), and for each service it retrieves the path to the service. So it should be possible to go the other way too. If you know the NAV Server installation folder, find the Service that is runnig from that folder, then check whether the service is running.

    As for how to see whether a service is a RTC Service or a Web Service service, quote from a previous blog:

    "It depends on the name. If it starts with "MicrosoftDynamicsNavWS", then it will be for Web Services. If the name starts with anything else, then it will be for middle tier for RTC clients."

    blogs.msdn.com/.../creating-a-web-service-manually-the-importance-of-what-name-you-give-it-and-a-few-small-things-to-remember.aspx

Page 1 of 1 (2 items)