Tutorial: Use a CSV file to make a graphical menu of PowerShell scripts

I’ve recently been working on a PowerShell module that uses a CSV file to create a custom menu of scripts.

It looks like this:

It hopefully helps to bridge the gap between engineers and automators, who write scripts useful to others, and service desk people and technicians, who may not be confident with the command line. PSScriptMenuGui allows PowerShell coders to put their scripts in a simple menu, usable by anyone.

It’s loosely inspired by (criminally similar to) something I made for a previous employer.

(The main difference is that this version starts instantly. The old version was so slow that I made an entertaining loading screen to fill the void. A good subject for a future blog post…)

If you’d like to dive straight in, please:

The rest of this blog post acts as a tutorial.

If you’d like to be guided through making your own menu, keep reading…

Step 0: System requirements

The module works on Windows only – sorry, rest of world!

Apart from that, it should run pretty much anywhere. It works on:

  • PowerShell for Windows 5.1 which comes with Windows 10.
  • PowerShell 7, currently available as a preview and due to be finished at the start of 2020.

It does not work on PowerShell Core 6. If you have this version, the easiest solution is to use PowerShell 5.1 as it is already on your PC.

Step 1: Install the module and make an example menu

Open a PowerShell prompt and:

# Navigate to where you want to work on your menu - in my case OneDrive:
cd $env:OneDrive
# Install the module:
Install-Module PSScriptMenuGui -Scope CurrentUser
# You may need read and agree to messages about updates and trust
# Make an example menu to get you going:
New-ScriptMenuGuiExample

You should see this:

VERBOSE: Copying example files to PSScriptMenuGui_example...

Step 2: Explore the example

Navigate to your PSScriptMenuGui_example folder and open PSScriptMenuGui.ps1. You should see a bit of boilerplate to ensure that the module is loaded, followed by this line which displays the menu:

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

Try running the line in your PowerShell window. You should see the example menu from the GIF at the top of this post.

Now open example_data.csv. A text editor is fine but Excel is easier. You can see that every row in the CSV represents an item in the menu.

Step 3: Make it your own

Experiment with editing the CSV and running the Show-ScriptMenuGui command again to see your changes.

A few ideas:

  • Put one of your scripts in the folder and add it to the menu using Method powershell_file and Command .\filename_of_script.ps1.
  • Try including PowerShell commands in the CSV file. Use Method powershell_inline and Command Get-ComputerInfo. Run Show-ScriptMenuGui with -NoExit to stop the PowerShell window from closing.
  • Add a link to an external application. Use Method cmd and enter the path of the program in Command.

Step 4: Next steps

Step 5: Make a shortcut

When you’re happy with your menu, why not make a shortcut to it in File Explorer?

  1. Right click a blank area in a folder window or on your desktop.
  2. Select New → Shortcut
  3. Enter something like this as the location:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\full\path\PSScriptMenuGui_example\PSScriptMenuGui.ps1"

8 thoughts on “Tutorial: Use a CSV file to make a graphical menu of PowerShell scripts

  1. I have a little exe that does something similar. Allows various commands and scripts to run. It’s particularly useful to runas with my different user roles, so I can start admin level apps without multiple clicks and id/password entry.

  2. This menu system is fantastic! So easy to build and run. Now my question is, after I open a PowerShell window from the menu, can I use the menu to run more commands from the open PS shell? For example, I created a menu item to connect to Azure. Now within the Azure shell I would like to run a command. It would be great if I could create another menu item to run my command inside of the window I just opened. Thanks!

  3. I love this but is there a way to create a CSV file for side by side buttons as my list of buttons is getting rather LONG

  4. Great tool, could you add an option that the buttons appear side by side. With over 30 entries it is exhausting to scroll

  5. Again have to agree this is a great tool for a novice like me and I have managed to create a menu for all of the team to use to connect to various servers they need in their day to day job. I like both John and Dan M above have the issue that scrolling in the window is getting a pain it is a long list of servers so some option to make the buttons appear in a second column after a number of entries would be fantastic.

    I have attempted to play around with the start.xaml file as Im sure it would be changed in there but other than managing to reduce the size of the buttons (which has helped) I dont have the knowledge to see how this could be forced to use a second column of buttons after ‘n’ number of entries?

  6. Hi,
    Love the tool, it helps in many small ways.

    I do have one problem though.
    when I add an option like this:
    Development Tools,cmd,C:\Users\test\AppData\Local\Programs\Microsoft VS Code\Code.exe,,Visual Studio CodeElevated,test
    The file cannot be found – I suspect that its due to the spaces in the path to the exe. I have tried escaping the spaces using the usual methods but no luck.
    I guess I could add the program(s) to environment path – but that might not always be practical.

    Any idea as how to solve this ?

Leave a Reply

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