imported module functions work local but not remote

Welcome Forums General PowerShell Q&A imported module functions work local but not remote

This topic contains 2 replies, has 2 voices, and was last updated by

5 years, 3 months ago.

  • Author
  • #12105

    Points: 0
    Rank: Member

    Powershell 1.0

    Hello. I imported the LocalUserFunctions from Hey Scripting Guy at and imported it into a module. I can use the functions locally but not via invoke-command or enter-pssession. I get the following...

    "The term 'set-LocalUser' is not recognized as the name of a cmdlet, function, s
    cript file, or operable program. Check the spelling of the name, or if a path w
    as included, verify that the path is correct and try again.
    + CategoryInfo : ObjectNotFound: (set-LocalUser:String) [], Comma
    + FullyQualifiedErrorId : CommandNotFoundException"

    Could this be a powrshell version thing? Thanks in advance for your insight\help!

  • #12111

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    There could be a lot of things wrong.

    First, PowerShell 1.0 does not support modules and does not support remoting. You indicated that you are using PowerShell 1.0. Enter-PSSession would not work.

    Second, if a module is installed on your local computer, that does not automagically make it available on the remote computer. If you ask the remote computer to run a command, the command must be ON that computer. You might, for example, copy the script module to the remote computer, preferably putting it into one of the locations set in the PSModulePath environment variable.

    Third, PowerShell v2 will not auto-load a module just because you tried to execute a command in that module. You must explicitly load the module into memory by using Import-Module. v3 will auto-load modules IF the modules are located in one of the paths set in the PSModulePath environment variable.

    Fourth, if you use Invoke-Command with -ComputerName (instead of -Session), then the remote session will spin up, run the command, and spin down. That means, if you use Invoke-Command to import a module on the remote computer, it will not "stay" imported.

    Hopefully some of that will shed some light on what's going wrong for you.

    • #12177

      Points: 0
      Rank: Member

      Thanks for the info. Using the information you gave me, I'll see what I can do when I get some time.

The topic ‘imported module functions work local but not remote’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort