How to use templatefile to pass a powershell script into CommandToExecute

For archive, answered duplicate of this question is here