The script block does not receive $thisId , and it is set to null. Therefore stop-process gives an error. You can pass arguments to a script block, as mentioned by @Rynant.
Since all you do is get the processes and kill the processes matching your requirement, move the commands to the script block and execute this script block as a whole using Invoke-Command in the remote field:
$script = {Get-Process -name uniRQBroker,uniRTE | stop-process -passthru | %{write-host killed pid $_.id}} invoke-command -script $script -computer $destPS
source share