Creating Script Modules

Welcome Forums General PowerShell Q&A Creating Script Modules

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

5 years, 5 months ago.

  • Author
  • #10934

    Points: 0
    Rank: Member

    I have 3 powershell scripts that I created. Now, I want to deploy them to a common server to which various users will have access(using powershell web access) and they can issue cmdlets that I created.

    Initially I thought, it would be a pretty simple process. But may be I was wrong or may be I am missing something.

    To create a Script module, I copied all my scripts into a single psm1 file.
    Next step was how to make sure this is registered. I followed below post to register the module file.

    But for some reason I am still not able to see my cmdlets in new session. Are there any clear steps i can follow or what is it i am not doing correctly.

    Again, i was not able to edit the PSModulePath using the script in above link so i edited the env variable manually and added my module path. Still i dont see my cmdlets. Please help!

    Thanks for the anticipation in advance.

  • #10938

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    What matters is WHERE and HOW you edited your PSModulePath environment variable. You can't do it from within PowerShell – that won't change anything more than the current session. You need to persistently change PSModulePath by changing it from the Windows Control Panel or via GPO.

    And you're technically not "registering" the module. It simply needs to live in a place where PowerShell knows to look for it, if you want module auto-loading and auto-discovery to work.

    You should be able to open a new shell session, run "$env:psmodulepath", and see your revised PSModulePath. If you don't, then you need to solve that.

  • #10966

    Points: 0
    Rank: Member


    Thanks for the reply. May be i was not explicit in my last line of previous post for setting environment variable. I have set the environment variable manually from control panel.
    Now, When i run $env:PSModulePath in a new session of powershell I could see my path there.

    But not sure if that path is getting scanned or not, i dont see my modules being registered.
    I also tried adding export-modulemember -function

    Not sure what else i am missing.

The topic ‘Creating Script Modules’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort