I got this to work after a while, couldn't understand why the suggested try didn't.
At the end I got the following script
Invoke-Command -ComputerName $servernamn -Credential $credetials -Scriptblock {
cd "D:\temp\"
./custom.exe
}
I don't know why there is a difference in running the program AFTER i change directory but apparently there is. Anyway this works and if somebody have the same problem try this.