Powershell Visual App to manage Nav bases

As you probably know, Powershell is a very usefull tool to manage Nav bases and automate administrative tasks. If you don’t hear about Waldo’s Powershell module, you need to visit the following link. He create a lot of usefull functions to enlarge the Microsoft panel of Powershell cmdlet http://www.waldo.be/2017/01/17/powershellget-waldos-powershell-modules/

For my company we have to regulary update test/developement base data from a production base. That not as easy as you think when you have intercompany, EDI and other links in the base you don’t want to keep for the tests. We decide to find a way to automate this task :
– Create a codeunit to export and import sensitive data
– Create a powershell to export fob, export sensitve data, then import a database backup, import fob and import sensitve data back.

As this powershell function need parameters I got fun searching arround how to create a visual way to put them and find this wonderful post

Here we are when Visual Studio XAML, Powershell and Nav combine together :

How it work :

Just select a backup file and destination service, click on “Execute copy”. Powerhsell will do all the administrative task for you : exporting data and fob, importing backup, reimport data and fob and finally restrart Nav service. If you do not have source control you can use this for archiving fob file ticking the option “Keep fob file”. This can probably be achieved with some rapidstart package but click on only one button is better 🙂

Interesting technical functionalites :

  • Using XAML visual form with Powershell
  • Create an executable from a ps script with PS2EXE : https://gallery.technet.microsoft.com/scriptcenter/PS2EXE-Convert-PowerShell-9e4e07f1
    (don’t use gui parameter when you use it for a xaml powershell application) here the zip of my modified version of ps2exe automating ps convertion to exe with an ico : PS2EXE.zip
  • Show/Hide original Powershell console with XAML
  • Force the script to launch in admin mode
  • Retrieve a Nav service informations from his name (database name/server)
  • Force a Nav database backup restore (dropout immediatly all connections and handle logical file name for .bak containing different database name then destination)

PS source code available here MountNav_TestDB.zip

Leave a Reply

Your email address will not be published. Required fields are marked *