There are different ways to use powershell scripts in agent procedures.Either I write the script as usual and upload the script via managed files to the VSA server and then use it:
using writefile to upload scripts to endpoints is pretty much the only thing that works consistently for me.
If the script isn't too long you can use a semicolon to have multiple lines into one line.
We also use "echo" to build ps1 powershell scripts on the fly. It's especially useful when using #vars#. Seems to work pretty well. no complaints.
Another method is using the pipe | in the command line.