Function to "Tool"

This topic contains 3 replies, has 4 voices, and was last updated by Profile photo of Istvan Szarka Istvan Szarka 2 years, 10 months ago.

  • Author
    Posts
  • #15911
    Profile photo of Tracy Johnston
    Tracy Johnston
    Participant

    After listening to Don Jones at Teched I ran back to the office and created a few functions(with examples,help and no write-host"). I now want to give this function to people on other teams. What is the best way for me to deliver this. I do not want to load it in everyone's powershell profile. Is there a place I can store the PS1 that will auto pull it in for all users on a server?

    Thanks

  • #15912
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    Ideally, you would place this function into a module (psm1 file), and place it in the module path for the server. (In PowerShell 4.0, the ideal place for this is "C:\Program Files\WindowsPowerShell\Modules" ). Then it becomes available for everyone to import as a module, and if running PowerShell 3.0 or later, module auto-loading will allow them to run it right away (without an import command first.)

  • #15952
    Profile photo of Istvan Szarka
    Istvan Szarka
    Participant

    Or you could add a shared folder path to the PSModulePath environment variable and put your modules there. I guess you could do that with Group Policy or DSC. This way, you wouldn't have to put it into PowerShell's folder on every server.

  • #15914
    Profile photo of Martin Nielsen
    Martin Nielsen
    Participant

    A network share works too.


    Import-Module \\server\share\module.psm1

You must be logged in to reply to this topic.