Question

I have a module located on a network share the I wish to load during remote session to other servers on my network.

Here my commands:

enter-pssession remoteserver
import-module \\shareserver\sharefolder\SPModule.misc

Here is the error:

Import-Module : The specified module 'SPModule.misc' was not loaded because no valid module file was found in any module directory.
    + CategoryInfo          : ResourceUnavailable: (SPModule.misc:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

Are modules not able to load from network shares or what am I doing wrong?

Thanks

Was it helpful?

Solution

OTHER TIPS

By default, it looks for modules by name in whatever path(s) are listed in the PSModulePath environment variable. I know you can also provide an absolute path, but I've never tried a UNC.

That said, module filenames end in either .psm1, .psd1, or .dll - ".misc" isn't a valid module filename. From the help:

Specifies the names of the modules to import. Enter the name of the module or the name of a file in the module, such as a .psd1, .psm1, .dll, or ps1 file. File paths are optional. Wildcards are not permitted. You can also pipe module names and file names to Import-Module.

If you omit a path, Import-Module looks for the module in the paths saved in the PSModulePath environment variable ($env:PSModulePath).

Try renaming your module to .psm1 (if it is in fact a Script Module).

When a PS session is created and authenticates through Kerberos, the session doesn't support double hop. Therefore, the PS session can't authenticate by using network resources.

Resolution: On the computer that is the target of the Enter-PSSession command, run this command:

> Enable-WSManCredSSP -Role Server

On the computer on which you run the Enter-PSSession command, run this command:

> Enable-WSManCredSSP -Role Client -DelegateComputer Servername

Reference: https://support.microsoft.com/af-za/help/4076842

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top