The reason it did not work is due to the Set command.
The first solution I found by trial and error. Once I knew what the cause of the error was I was able to find a possibly better - depending on you scenario - solution via the Dopus forum search.
First solution was to put the string Set in to a variable and use the variable.
@leavedoswindowopen
@nofilenamequoting
echo %0
@set varSet Set
{$varSet} filePath={filepath$}
{$varSet} escapedFilePath=%filePath:'=''%
powershell "& write-host '%escapedFilePath%'"
The other solution was to use the externalonly only command as described here
@leavedoswindowopen
@nofilenamequoting
@externalonly
echo %0
Set filePath={filepath$}
Set escapedFilePath=%filePath:'=''%
powershell "& write-host '%escapedFilePath%'"
Both produce the same output batch file. The second solution is no good if you want to run some Dopus internal commands.
Time for a celebratory coffee.