1

I have a script, and it primarily defines just one function. If the script is merely included

. .\MyScript.ps1

Then I want to let it be used as a regular function

My-Script <args>

But if it's right-click-run from Explorer I want to have it trigger a portion of the file to be run making the file self-calling. (eg: at the end of the file include some My-Script <args> of my own devise that are already in the file)

Can this be done?

If there is a requirement for PowerShell 2.0 or 3.0, that can be arranged as a pre-req if need be.

jcolebrand
  • 15,889
  • 12
  • 75
  • 121

0 Answers0