If you're running this script in the actual script window in the GSS task (and not as a .ps1 file) then you may need to put
#powershell in the first line. They talk about it a bit in
this thread. I would imagine this is the problem as
error 255 is a generic batch script error.
If you're still having issues, you can paste this script into a ps1 file and execute it via command with something like this:
PowerShell -ExecutionPolicy Bypass -File C:\temp\myscript.ps1This is of course assuming you have permissions to do so, although this could be considered risky behavior and may be picked up by antivirus monitoring.