I have written a script that will execute a script in the remote machine.
Script is organised in the remote machine in the following way,
lib - this is where library filea are located
tests - this is where test scripts are located
The script in the remote machine(in the tests folder) imports other modules from library folder like
Import-Module -Name "..\lib\commonlib.psm1".
Now when the script in the tests folder remote machine is invoked, there is any error
Import-Module : The specified module '..\lib\commonlib.psm1' was not loaded because no valid module file was found in any module directory(directory lib and commonlib.psm1 are present in the correct path)
How can this issue be resolved?
Below is the command to run the script in the remote machine.
$job = "c:\scripts\test.ps1" $cmdRes = Invoke-Command -ComputerName $remoteMachineName -ScriptBlock {& $args[0]} -ArgumentList $job -AsJob