Both scripts and functions (and any other script block, for that matter) can have a param statement. Typically, you’ll put functions that you intend people to call directly into a script module (psm1 file). Alternatively, they can dot-source the script first to load the functions into the PowerShell session before they can be used. If you use this method, your script should assume it’s going to be dot-sourced, and shouldn’t automatically execute any of its code (or have its own param block, most likely.)
What I’m suggesting is more like this:
function Do-Stuff { [CmdletBinding()] param ( $Parameter1, $Parameter2, $Parameter3 ) # Do stuff with parameters. # This function has no concept of a menu, and doesn't know that it's even possible to draw one. It just # works based on what gets passed in for Parameter1, 2, and 3. } function Show-Menu { # Display a menu. Based on user input, come up with values for $Parameter1 through $Parameter3, and call Do-Stuff }
Do-Stuff and Show-Menu would likely be in separate files (with the Do-Stuff tool ideally living in a PSM1 script module somewhere.) Show-Menu might even just be a script instead of a function.