Right. So, now that we’ve got the remote script working, we can work on that. Let’s do just one thing. I find it’s often easier to walk into things one step at a time, so if something breaks, you know exactly what it is.
I’m just curious to see what happens either way. Do make sure you’re running the shell as someone with remote access to the remote machine - normally, someone who’s in the local Administrators group on the remote box.
So the next thing is how to calculate the path to the ps1 file in a variable outside the ScriptBlock and then use that variable inside the ScriptBlock…
With the same result. In the Script window of the ISE I get a squiggly under the second “using” and if I hover over it the pop-up says “Unexpected token ‘$using:SDFEnvironment’…” You don’t get this error if you put this code into the Script window of the ISE? Can you share your $PSVersionTable?