Importing available module into PowerShell v2.0 results in error

5,989

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.

Share:
5,989

Related videos on Youtube

nerdenator
Author by

nerdenator

Updated on September 18, 2022

Comments

  • nerdenator
    nerdenator over 1 year

    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?

    • briantist
      briantist over 9 years
      Can you show us what the directory structure of the module looks like on the filesystem?
  • nerdenator
    nerdenator over 9 years
    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.