This topic contains 2 replies, has 2 voices, and was last updated by
December 22, 2013 at 8:35 pm #12105ParticipantPoints: 0Rank: Member
Hello. I imported the LocalUserFunctions from Hey Scripting Guy at http://gallery.technet.microsoft.com/scriptcenter/f75801e7-169a-4737-952c-1341abea5823 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!
December 22, 2013 at 8:53 pm #12111KeymasterPoints: 1,704Rank: 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.
December 24, 2013 at 8:34 am #12177ParticipantPoints: 0Rank: 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.