Search code examples
powershellshellcommand-linecommand-line-interface

How do I run my powershell script from any directory? (Like in $profile but in its own .ps1 file)


My .ps1 script is just a simple multi-argument function, but I want to run this function anywhere like functions in $PROFILE but for tidiness and organisation's sake, I want it to be its own file. If where I put it affects my code, I'm making a cli for a package installer called mint. I tried many articles and posts, but none of them worked. Thanks!


Solution

  • If it's a simple script, just Dot-Source it in your $PROFILE.

    If it's more complex, check out Modules