I have some trouble to start a batchfile or ps1 file on a remote system with invoke-command. I know that when starting such a script or batch in powershell on a networkshare that there is some problems with double hop. So i first copy the files to the local system, that is a challenge already because i the copy command is in the batchfile or script that i want to execute on the remote pc or server.
What i have tried is directly read the batch or ps1 from a networkshare but that gives me a access denied, i think double hop. So then next:
$computerName = 'testpc'
Copy-Item -path \share\uninstalsp.bat -Destination \$computername\c$\temp\uninstallsp.bat
Copy-Item -path \share\bas.bat -Destination \$computername\c$\temp\bas.bat
invoke-command -computername $computerName -scriptblock{Start-Process "C:\temp\uninstallsp.bat"}
invoke-command -computername $computerName -scriptblock{Start-Process "C:\temp\bas.bat"}
After this there is no error but nothing happens on the remote system. I have already had this before with other files, no error but nothing happens. In this example i try to uninstall a program, in the batchfile there are some registry keys changed and the uninstall certain software is executed so the last batchfile must wait for the first.
What am i doiing wrong? And how can i run this without copy the files to the local system and complicated double hop?