Trustworthy Folders

by Jun 22, 2009

If you want to launch a script file or executable, in PowerShell, you'll need to specify either a relative or absolute pathname. To do so by name, you’ll need to make sure the folder is trustworthy, which could be done simply by adding it to the PATH environment variable.

For example, to make the folder c:myscripts trustworthy, simply execute this command:

$env:path += ';c:myscripts'

Any script or executable stored in c:myscripts is now accessible by name. If you have saved a PowerShell script named myscript.ps1 in this folder, you will now be able to launch it simply by typing:

myscript (Enter)

To make this change permanent, you’ll need to add the command to one of your profile scripts, which are executed automatically when PowerShell launches. Otherwise, your changes will be discarded once you close PowerShell since changes to your environment variables are temporary.