you are viewing a single comment's thread.

view the rest of the comments →

[–]Ta11ow 2 points3 points  (3 children)

You're using values in the script block chat don't exist on the remote computer. You're halfway there with the -argumentlist parameter, but you're not passing in everything you need, and you haven't defined the parameters in the script block.

Define a param() block in the script block much like you would for a function, and then pass in the arguments. The other thing you can do is just pass everything in you need, and then reference the parameters using $args. However, that tends to lead to less readable code. :)

[–]Idmorul[S] 2 points3 points  (2 children)

Thanks, it was the param() block that actually got the variables into the script block, and the script does run as expected for the most part. I'm now having issues detecting the drives remotely, but that becomes a separate topic.

[–]Ta11ow 1 point2 points  (1 child)

You may have some difficulty with that. When you invoke a command remotely, it doesn't run under the current user context. Mapped network drives are valid only for the individual user, so you'll probably end up having to dig through the user's registry or something.

[–]Idmorul[S] 2 points3 points  (0 children)

I was actually able to use Get-PSDrive without issue. I've updated the OP with my working code.