In this guide, I’m going to show you an incredibly simple way to create a menu to display all of your most-used Powershell scripts.

In this tutorial, I am using PSScriptMenuGui. This module uses a simple 6-column .CSV file, which is where you will specify things like the script path, button name, section, and description. I went with this option because it was by FAR the easiest way to create a simple menu for myself and our IT department to use and manage. I didn’t want to spend the time to cobble together something using Windows Presentation Framework (WPF) or use PoshGui, because based on some of the other guides I’ve found online – that could be a very long and daunting process.

All I want is a simple way to click a button and run a Powershell script, so PSScriptMenuGui fit the bill and works really well.

Note: I have links below for each of the scripts in my header image.


Why use a Powershell GUI?

There are a number of reasons why you should consider using a GUI to manage your scripts. Here’s why I use one:

  • Quickly access your most used scripts
  • Organize scripts
  • Simplifies onboarding/offboarding of new hires or terminated employees
  • Allows you to share your scripts with other employees (without them having to right-click and Run With Powershell)
  • Deploy scripts in one-button click
  • Give additional notes about what each script does in case there is any confusion

Let’s say you are in the process in the automating your new hire process.

You start creating Powershell scripts for things like Create New Active Directory User, Create O365 mailbox, move the user to a certain OU, send a welcome email, etc.

That’s great! Unfortunately, now you are left with a folder full of scripts.

How do you delegate running these scripts for your IT staff? Do you just name the scripts Step1_NewADuser.ps1, Step2_CreateO365user.ps1?

This was exactly the same problem I ran into, and why a Powershell GUI makes the most sense. With this solution, the file name doesn’t really matter because they are just clicking a button. You can also add a description to give more context before the user runs the script, or simply use the description field to number your steps.

If this is something you’d like to setup, follow the instructions below.


Step 1: Install Powershell Script Menu Gui

The Github link to this project can be found here: https://github.com/dan-osull/PowerShell-Script-Menu-Gui

Open Powershell and type this command:

Install-Module -Name PSScriptMenuGui

Click Yes in the popup box to install the Nuget repositories.

Click Yes to All on the external repositories box:

That’s it, the module is now installed.


Step 2: Create CSV File

To simplify things, you should create a folder where you’ll be dropping your completed files into. This is also where your .csv file will go. (mine is named ITgui.csv in the image below)

I created a C:\Scripts\Final folder, which is where all my completed scripts will go.

In your newly created .csv file, add these 6 column headers: Section, Method, Command, Arguments, Name, and Description.


Step 3: Add Your Scripts

I’m only adding Powershell scripts to mine, but you can add Windows programs and CMD commands to this as well.

The rest is pretty self-explanatory. You can reference my .csv above to give you an idea of how to lay things out.

  • Sections: Give your section a name (i.e – New Hire.) All scripts with the same section name will be grouped together in the frontend menu.
  • Method: Valid options here are:
    • powershell_file
    • cmd
    • powershell_inline
    • pwsh_file, pwsh_inline
  • Command: Path to script or executable
  • Arguments (optional): Specify any arguments you want to pass to the target script
  • Name: Button name
  • Description: Button description

Step 4: Launching Your Powershell Menu

Create a new .ps1 file and paste in the below command. This is the command that will launch your menu script.

The only thing you’ll need to change is the .csv path to the location yours is stored. Then, save your .ps1 script to your Scripts folder (C:\Scripts\Final) and give it a name (IT-Script-GUI.ps1).

Show-ScriptMenuGui -csvPath '.\ITgui.csv' -Verbose

Then, just right-click the IT-Script-GUI.ps1 file > Run With Powershell and your brand new menu should open!

If the menu doesn’t open, set your execution policy first:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

You may notice that this program has the default title Powershell Script Menu, you can’t change the button colors, etc. If you’d like to further customize your menu, you can use the below command inside your .ps1 instead. Just change the .csv path, select a new color, and then change the Window Title fields. Everything else can be left as is.

#region Setup
Set-Location $PSScriptRoot
Remove-Module PSScriptMenuGui -ErrorAction SilentlyContinue
try {
    Import-Module PSScriptMenuGui -ErrorAction Stop
}
catch {
    Write-Warning $_
    Write-Verbose 'Attempting to import from parent directory...' -Verbose
    Import-Module '..\'
}
#endregion

$params = @{
    csvPath = '.\ITgui.csv'
    windowTitle = 'IT Shared Scripts v1.1'
    buttonForegroundColor = 'Azure'
    buttonBackgroundColor = '#eb4034'
    hideConsole = $true
    noExit = $true
    Verbose = $true
}
Show-ScriptMenuGui @params

Step 5: (Optional) Converting your Powershell Script to an EXE

This step is optional, but if you’d like to turn your completed GUI Menu script into an actual program, it’s super easy to do. The main I chose to do this is so I can pin the program shortcut to my taskbar or desktop for quick access.

To do this, I used a program called PS2EXE.

Open a new Powershell instance and type this command to install the module.

Install-Module ps2exe

Then, simply change the Source and Destination paths. The Source is the first path below, the destination where the .exe will go is the second.

Invoke-ps2exe C:\Scripts\Final\IT-Script-GUI.ps1 C:\Scripts\Final\ITtools.exe

Note: The Destination should go to the same folder as your .csv file. Otherwise, the menu won’t load because the CSV file paths will be incorrect. You could also hardcode paths into the .csv.

Obviously having your IT techs browse to a file share to launch the menu isn’t ideal, so let’s create a shortcut.

Just right-click the ITtools.exe from within your Scripts folder > Create a Shortcut. Then, just drag it to your desktop or pin it to your taskbar.

Then, add an icon by right-clicking the shortcut > Change Icon.

You can now pin it to your taskbar for quick access!

For testing, I have the scripts folder on my local machine. Once I provide the Powershell Menu .exe to my IT technicians, I will move the scripts to our IT network share, update the paths in the .csv, and then create a new exe.


Wrapping up

That’s it! Hopefully this guide shows you how to create a Powershell GUI quickly and easily in 2021!

This post is a part of my Automating New Hires With Powershell series, where I create a bunch of helpful Powershell scripts. Below is a few links to some of the scripts I have running in my Powershell GUI.


My Homelab Equipment

Here is some of the gear I use in my Homelab. I highly recommend each of them.

The full list of server components I use can be found on my Equipment List page.

Similar Posts

15 Comments

  1. Hi Danny, thanks for sharing, looks great. Does this allow the option for users to run PS commands as standard user that require admin? E.g. an uninstall script or install printer script?

  2. Hi Danny, thanks for sharing, looks great. How can increase the Menu Window to Full Screen?

    1. You’re welcome! I still use this everyday and love how easy it is to use once it’s setup.

      Good question though – I’m actually not sure. I run mine in the default window. Considering it adds the buttons in a long lost, I don’t know how helpful it would be having it be fullscreen anyway.

  3. Jim Booth says:

    Hi Danny
    Just like to say a massive thanks for this. I am a complete utter novice at Powershell having had it hoisted upon us by our organisation but have managed to produce a menu for the users that launch a connection script following your article.
    A question if I may is it possible that the menu could have say Just “New Hire” then “Termination” but when th euser clicked either word would then expand buttons under that section as I have a vast number of scripts to add and would be great if the menu items could be collapsed until needed ?

    1. You are very welcome! I’m glad you found it useful and are using it in production.

      Since I didn’t write the script, I’m not sure if you can make it collapsible (although that would be a neat feature!) I’m sure it’s possible with some custom code, but I’m not even sure where to begin adding that. Sorry about that!

  4. Hi Danny, thanks for sharing this Powershell GUI menu. I am definitely considering it. So far in my lab environment I have this working beautifully and the PSScriptMenuGui loads perfectly. However, whenever I go to my customer server environment, I get the following error from the powershell ISA interface.: Any ideas on how I can fix this?

    Error-1
    PS C:\EVXEnvScripts\Scripts\GUIMenu\PSScriptMenuGui> Install-Module -Name .\PSScriptMenuGui
    PackageManagement\Install-Package : No match was found for the specified search criteria and module name ‘.\PSScriptMenuGui’. Try Get-PSRepository to see all available

    registered module repositories.

    At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21

    + … $null = PackageManagement\Install-Package @PSBoundParameters

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo : ObjectNotFound: (Microsoft.Power….InstallPackage:InstallPackage) [Install-Package], Exception

    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

    1. The error looks like it didn’t download the package correctly. Try running through Step 1 again and/or rebooting after running it.

  5. Hi Danny,

    Looks like I received the same error as before after the server reboot. I will try to download again, but I am not confident.

    Others are having similar issues loading other modules and after they step through a few suggested solutions they all work, except for mine….

    Any other suggestions or how can I compare downloads with the zip, let me know. I’m stuck – Thanks.

  6. Hi Danny,

    Just found out the server I’m trying to run your GUI menu from has no internet connect and an isolated network infrastructure. Would you happen to have a way for me to get a list of what is need to be downloaded from Powershell and I can always FTP them into the correct Windows folders to make them available.

    Please let me know if this is possible….

    Thank you!

  7. Frank Del Buono says:

    Thank you for your response again. I will give it a try

  8. Frank Del Buono says:

    Danny, would you happen to have a list of the powershell comlets I need to download for the GUI menu app you recommended. I don’t believe I will be able to find out which ones I need. If I can figure this out, I may be able to get all this to work.

    Thanks again!

  9. Anyway to reuse the same powershell window or session that is first opened using a command and have another button (command) use that window. . Example, Connect-ExchangeOnline. After connecting to exchangeonline I want to run a mailbox command. But if I make a new button with a command it will run it in a new powershell window and that window doesnt understand the exchange commands

  10. Hernan Maslowski says:

    Hey Randy, do you have any clue on how to run Exchange Powershell Script, everything related with exchange requires the exchange console if not fails.

    Thanks

  11. Hey Danny, thank you for sharing this, it will be quite helpful when I want to create scripts or .exe’s for our techs to use. One issue I am having is that when I click on one of the menu buttons a PW window pops up but then immediately closes before I can do anything. Any idea what I might have done wrong?
    Thanks.

Leave a Reply

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