imported module functions work local but not remote

Powershell 1.0

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
ndNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException”

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

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.

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