Create Your Own Right Click Tools – Part 3

2 minute read

In Part 1 of this series, I showed you how to find the GUID of the menu. In Part 2, I showed you how to create a menu item and run a script. Now, I’ll list some tips I’ve found as I’ve worked on the Powershell Right Click Tools.

1. Add Sub Menus 2. Run Powershell Scripts

1. Add Sub Menus

I’ve taken the “Content Status” menu option we created in Part 2, and added it to the group “Test Group”

<ActionDescription Class="Group" DisplayName="Test Group">
		<ActionDescription Class="Executable" DisplayName="Content Status">
			<Parameters>-sta -windowstyle hidden -executionpolicy bypass -file "C:Content Status.ps1"</Parameters>


Line 1 creates the group name “Test Group”.  Line two tells the console where to display this new group.  Line three starts the ActionGroups, and anything under here will show up in the menu.  As you can see, I put my Content Status menu executable under here.  Now, when I open the console, I see Content Status in the menu Test Group.

And that’s how you’d create sub menus!  You can even create sub menus of sub menus of sub menus if you wanted. I don’t know if there is a limit to how deep you can go.

2. Run Powershell Scripts

Powershell scripts don’t run straight out of the box like VB scripts do.  To run a VB script, you just need to put wscript.exe as your executable, and then the script name as your parameter. If you tried this with Powershell, it wouldn’t work! Why is this?  Execution policy!

The odd thing about the ConfigMgr 2012 console is the execution policy is different than the computer’s execution policy. To illustrate this point, I created a right click tool that simply runs a batch file to read the powershell execution policy. Here is a snap shot. The window on the left was run file normally to get the computer’s execution policy, and the right was run through a right click tool to get ConfigMgr’s execution policy:

ConfigMgr’s execution policy doesn’t mirror the execution policy of the computer. So, how do I launch all my Powershell Right Click Tools? I use a number of switches to force them to display.  The first switch is –ExecutionPolicy, which I set to bypass. I then also set –WindowStyle Hidden and –Sta when I’m running a Windows Forms script, to hide the ugly console window. To launch a powershell windows forms script with no arguments, here is the parameters line:

Leave a Comment