Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Using session to add central module path to remote machines

$
0
0

Rather than updating the PSModulePath variable on all your machines, a possible alternative is to use a full path to the module in the Import-Module command of whatever scripts are using it. I haven’t tried using a UNC path in this situation, but it’s worth a shot.

Import-Module '\\server\share\folder\PSWindowsUpdate'

From a performance perspective, it might be even better to have your script copy down the module to the local machine, then import the local copy into your PowerShell session:

if ((Test-Path -Path "$home\Documents\WindowsPowerShell\Modules") -eq $false)
{
    $null = New-Item -ItemType Directory -Path "$home\Documents\WindowsPowerShell\Modules"
}
robocopy '\\server\share\folder\PSWindowsUpdate' "$home\Documents\WindowsPowerShell\Modules\PSWindowsUpdate" /MIR /DST

Import-Module PSWindowsUpdate

Viewing all articles
Browse latest Browse all 13067

Trending Articles