The Microsoft All-In-One Code Site has a new NAV code sample. This time it demonstrates using PowerShell to
- Get a list of NAV 2009 Services, either on the local machine or on a remote machine, and
- 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