How to display a message box in Powershell

I have just finished writing a proof of concept GUI app using Powershell that takes DHCP reservation details and writes them to our two DHCP servers.  This has already proved a time-saver as usually we have to input this same reservation info twice. (Once per server as we use two servers for redundancy and therefore need to have the same reservations on both servers)

Here’s a screenshot of what the GUI looks like:


I’m currently breaking down my functions that were used in the script and turning them into modules for use in  future scripts that I write.

I’ve started with the easiest, which simply displays a message box to the end user.  There are parameters to change the icon and button configuration as well as sample code on trapping responses which you can find by running: help Show-OHMessageBox -full in Powershell)

Here’s an example of a message box:


To use it, download the file, unzip it and place the OHTools folder in C:\Users\<username>\My Documents\WindowsPowerShell\Modules  (NB You may have to create the ‘Modules’ Directory.)

The final unzipped path should be: C:\Users\<username>\My Documents\WindowsPowerShell\Modules\OHTools and in the OHTools directory should be a single file called: OHTools.psm1

Once that’s done, simply fire-up Powershell and start using it by typing: help Show-OHMessageBox -full

The next function I’ll be adding to the tool-set is a MAC Address validation routine. I’ll update OHTools once it’s complete.

Be the first to comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.