Utilizing the Windows Powershell Script Folder

This topic contains 3 replies, has 4 voices, and was last updated by  Rick 3 weeks, 6 days ago.

  • Author
    Posts
  • #80068

    Wei-Yen Tan
    Participant

    Hi,

    I am writing a script that I would like to call from a central location. I saw that Powershell has a Script folder. How can I utilize this folder so that any user can use this script in the console? TIA

  • #80069

    Snak3d0c
    Participant

    I'm unsure as to what you are referring but,
    I'm guessing it is $PSScriptRoot. This refers to the folder from where you run the script.

    You could go about it different ways but if you were to store the scripts in a Folder where you set NTFS-security on (and share it). It should be available to everyone (within your security parameters).

    You could also include it in the powershell profile. But that gets dirty quite quickly in my opinion.

  • #80075

    Don Jones
    Keymaster

    PowerShell doesn't have a central folder where it looks for scripts.

  • #80159

    Rick
    Participant

    You can do something like dot sourcing your scripts folder in your powershell profile. If your scripts are not local you will need to digitally sign them or decrease the executionpolicy from remotesigned to unrestricted(BAD)!!

    http://woshub.com/how-to-sign-powershell-script-with-a-code-signing-certificate/

    http://www.gsx.com/blog/bid/81096/enhance-your-powershell-experience-by-automatically-loading-scripts

You must be logged in to reply to this topic.