Function or Module, how to

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

  • This topic has 2 replies, 2 voices, and was last updated 1 year ago by
    Participant
    .
Viewing 2 reply threads
  • Author
    Posts
    • #164472
      Participant
      Topics: 4
      Replies: 5
      Points: 38
      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: 9
      Replies: 1236
      Points: 4,443
      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: 4
      Replies: 5
      Points: 38
      Rank: Member

      Hello,

      Big thanks your advice!

Viewing 2 reply threads
  • The topic ‘Function or Module, how to’ is closed to new replies.