I've got a script that's on one of my servers.
I wanted to make a new script (which i can distribute to others at the IT-dept) that would enter a pssession and invoke-command the script.
I've been troubleshooting this issue for a while now, trying different ways and solutions, but it seems that whenever i enter a new pssession it doesn't load the remote filesystem but instead stays on local.
Running this:
Invoke-Command-Session$Session-FilePath C:\scripts\script.ps1
ends with error:
Invoke-Command : Cannot find path 'C:\scripts\script.ps1' because it does not exist.
At line:2 char:1
+ Invoke-Command -Session $Session -FilePath C:\scripts\script.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\scripts\script.ps1:String) [Invoke-Command], ItemN
otFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.InvokeCommandCommand
So tried just making a
etsn server01 -credential administrator
set-location C:\scripts
And that too fails with error that the path doesn't exist.
Any clues why this is happening?