I am trying to automate a process to uninstall an application on several servers. I have tried running the following commands remotely and they do not seem to work, however, when running locally it seems to run OK and I am not sure why it won’t work. PSRemoting is enabled.
I’d recommend to use Invoke-Command with the parameter -FilePath instead of -ScriptBlock. This way you can provide a local PowerShell script to run it on remote computers.
Please read the help completely including the examples to learn how to use it.
Thank you very much for this, managed to change my code entirely and it is working a treat. To help others if they experience the same issue I thought I would show my code.