Hello, I'm writing a script to test for a path on a remote computer and if that path is found take a certain action. The problem I'm having is test-path returns True regardless. Below is a sample of my script. Any idea why I get True but if I manually remote to the computer and run the same test-path command it returns false?
Check out the eBook link above and look for Secrets of Powershell Remoting. The first issue is that Test-Path is not in your script block, so it's not being executed on the client. Second, anytime you pass something outside of the script block, you need to use the using: keyword and leverage -ArgumentList to pass those parameters.