Function or Module, how to

Welcome Forums General PowerShell Q&A Function or Module, how to

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
2 months, 2 weeks ago.

  • Author
    Posts
  • #164472

    Participant
    Topics: 3
    Replies: 4
    Points: 18
    Rank: Member

    Hello,

    I have done some powershell scripts to the server.

    I would like make scripts to functions or modules so

    Everyone who has access to the server, so  they can call them

    From powershell command line without going to scripts location or import anything.

     

    Should I save them then %windir%\system32\WindowsPowerShell\v1.0\profile.ps1

     

    Or somehow to save to them as some modules.

    I think module is easy handle, so I can group Functions.

     

    How I can make module automatically activated so it doesn't

    Need to be loaded?

     

    Or how I should be doing this?

     

     

  • #164476

    Senior Moderator
    Topics: 8
    Replies: 1041
    Points: 3,440
    Helping Hand
    Rank: Community Hero

    From PowerShell version 3.0 on wards, any modules under the $env:PSModulePath locations will be auto loaded. You can place the module under any folder which is specified in that environment variable. Modules folder under $env:HomePath\Documents\Windows\PowerShell is the one which is recommended.

    The module auto load is handled using $PSModuleAutoLoadingPreference automatic variable, setting this to $false will disable auto loading feature.

  • #164482

    Participant
    Topics: 3
    Replies: 4
    Points: 18
    Rank: Member

    Hello,

    Big thanks your advice!

You must be logged in to reply to this topic.