I would like to have a custom context menu like the following:
Since this menu item does not follow the typical integration points for SPE, how would I go about making it work with a script?
The first step would be to create a custom script in one of your modules.
For example, create a custom SPE module using the wizard followed by whatever library structure you prefer. Check out the official SPE docs for additional details.
Show-Alert -Title "Hello!"
Close-Window # Causes the runner dialog to close automatically
Copy the item ID of the script.
Switch to the core database and create a new menu item. For the demo we'll create it at the following path:
# Item path
/sitecore/content/Applications/Content Editor/Context Menues/Default/Say Hello
The Message field should contain the following where the script parameter matches the item ID of the script.
Switch back to the master database and give the new menu item a try.
Note: Big thanks to Kurt Bilde for asking about it on Sitecore Chat.