ca9163d9
ca9163d9

Reputation: 29209

Share powershell functions for other scripts on multiple machines?

I have several functions which are called by many scripts located on the same or different machines on the same network (Company LAN). Is it possible to save/host these functions in one script instead of copy/paste them to every scripts?

function CommonFunc1($p1, $p2) { .... }
function SharedFunc2($p1, $p2, $p3) { .... }

Upvotes: 0

Views: 195

Answers (1)

campbell.rw
campbell.rw

Reputation: 1386

Create a module for the function to go in, and put that module on a computer that's reachable by all others via drive mapping or network share etc. Then you can import the module from that machine.

Like this:

Import-Module \\machine-name\C$\path\to\module\module.psm1

Upvotes: 2

Related Questions