New #requires parameters: -DotSource/-CallOperator, to allow script authors to indicate how the script must be invoked
Votes from Connect: 8
Original Date Submitted: 11/5/2015 5:13:13 AM
Handle: Kirk Munro
Site Name: PowerShell
Feedback ID: 1981963
Scripts are designed to be either dot-sourced, called, or much less often, both. Yet the vast majority of scripts out there don't have anything in place to make sure that they were invoked the right way. This can lead to a lot of confusion for script consumers that could be easily avoided.
I would like to see the #requires statement expanded with the addition of two new parameters: -DotSource and -CallOperator. When a script is invoked, PowerShell will check to see what the script requires (what invocation methods it supports), and if the invocation method that was used isn't supported by the script, then PowerShell could display an appropriate error message to the user so that they can invoke it correctly.
Product Studio item created by Connect Synchronizer due to creation of feedback ID 1981963 (http://connect.microsoft.com/PowerShell/feedback/ViewFeedback.aspx?FeedbackID=1981963).
Internal BugId: 15952