I created a binary C # module (in the form of a dll). I have it normally imported into PowerShell via the import-module cmdlet, and I also see it using the get-module cmdlet and its cmdlet run here, as they say, everything is OK. But my task is to import a binary module to a remote PC. But to import to a remote PC, it must have the property "imported into the session", i.e. when I Get-Module -ListAvailable , this module is invisible, of course, Invoke-command { import-module MyModul } -session New-PSSession -computerName 10.3.0.222 Gives the message:

The specified module "MyModul" was not loaded because no valid module file was found in any of the module directories.

 + CategoryInfo : ResourceUnavailable: (MyModul:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand + PSComputerName : 10.3.0.222 

My module is located in the C:\Users\Alex_Kot\Documents\WindowsPowerShell\Modules directory. This directory is set in the $env:PSModulePath environment variable, i.e. here everything is also kind of OK.

PS: I can not understand how I can make the module able to be imported to a remote PC.

    1 answer 1

    Import the module into the session object, like this:

     $Session = New-PSSession -Computername 10.3.0.222 -Credential (Get-Credential) Invoke-Command -Session $Session {Import-Module MyModul} Import-PSSession -Session $Session -Module MyModul