0

I'm trying to import a PowerShell module to do some SSH work. I've unlocked all of the files I'm trying to import in the module. The module itself is located in a directory where modules are to be located in order to be found.

PS C:\Users\AM034402> Get-Module -ListAvailable

ModuleType Name                      ExportedCommands
---------- ----                      ----------------
Manifest   SSH-Sessions              {}
Manifest   AppLocker                 {}
Manifest   BitsTransfer              {}
Manifest   PSDiagnostics             {}
Manifest   TroubleshootingPack       {}


PS C:\Users\AM034402> Import-Module SSH-Sessions
Import-Module : The specified module 'SSH-Sessions' was not loaded because no valid module file was found in any module
 directory.
At line:1 char:14
+ Import-Module <<<<  SSH-Sessions
    + CategoryInfo          : ResourceUnavailable: (SSH-Sessions:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

As you can see, PowerShell finds the module in the Available list, but trying to export it gets an error. I retrieved the file from this link on this wiki page. Any clues as to what is up here?

nerdenator
  • 103
  • 1
  • 3
  • Can you show us what the directory structure of the module looks like on the filesystem? – briantist Nov 03 '14 at 19:18
  • You downloaded the version designed for PS v2.0 right? Since you have tagged this Windows 7, I am curious why you haven't upgraded to WMF4. – Zoredache Nov 03 '14 at 19:29

1 Answers1

0

The issue occurs if the package is not available or resides in the wrong directory

PS C:\Windows\system32> Import-Module SSH-Sessions
Import-Module : The specified module 'SSH-Sessions' was not loaded because no valid module file was found in any
module directory.
At line:1 char:1
+ Import-Module SSH-Sessions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (SSH-Sessions:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

After reading this Q&A and trying to solve the issue the following answer has been formulated:

Download the SSH-Sessions.zip by clicking the download link on this webpage.

Extract the package to C:\Windows\System32\WindowsPowerShell\v1.0\Modules

Verify whether the package is available in PowerShell by issuing the following:

PS C:\Windows\system32>  Get-Module -ListAvailable

    Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------

Script     1.4        SSH-Sessions                        {ConvertFrom-SecureToPlain,
Manifest   1.0.0.0    StartScreen                         {Export-StartLayout, Import-
Manifest   2.0.0.0    Storage                             {Add-InitiatorIdToMaskingSet

If the module is available, it is possible to import it by executing Import-Module SSH-Sessions.

030
  • 5,731
  • 12
  • 61
  • 107
  • 1
    This worked. I also found that you should extract the files to a folder outside of your Modules folder, unblock the folder that contains the module, then copy it over. – nerdenator Nov 03 '14 at 19:59