I am working on a Powershell script to eliminate some of the manual configuration that's currently necessary to run it. One of the pieces of it is where I set a variable to send a deleted item to the Recycle bin or to delete it permanently.
Currently, that is a variable that I have set to either "Kill" or "Recycle" inside the script.
What I want to do is to prompt the user with the choices, but all I've found thus far is a repurposing of the msgbox that has YesNo, Yes/NoCancel, etc selections. Ideally, I'd like a message box to be presented with buttons that gives the user a choice between one or the other & set the variable based on what they clicked.
The prompt in the messagebox would say "Choose to Recycle (default) or to permanently delete files (cannot be recovered)". with buttons on the bottom saying Kill or Recycle, with Recycle selected. If they click the X on the box, it should default to Recycle.
The ideal solution would be if I had 3 choices (or more) and could present a messagebox with the options presented that would then store the response for later use.
This may be more suited to using another type of prompt, so I'm open to any alternatives. Any ideas thoughts appreciated.
You can do this with a dialog, but it's pure Windows Forms (.NET) programming. Bit out of scope for a PowerShell Q&A. You'd essentially need to construct a custom form - the built-in easy message box stuff only supports the canned buttons, not custom ones.
You CAN do a custom prompt that's more PowerShell-native - like the one that you get when you run Set-ExecutionPolicy. http://www.powershellcommunity.org/Forums/tabid/54/aft/3479/Default.aspx has a pretty good description, although it's for a yes/no prompt - you could obviously customize it. http://technet.microsoft.com/en-us/library/ff730939 is also a very clear implementation of the same technique.
I can make this suit my needs. Many thanks for pointing me in the right direction!