The script as written does not appear to need remote execution. I would recommend changing the PowerShell settings to their default, copy/paste the script into the script body, getting the script output and see if that works. It did for me. If it doesn't, take a screenshot of the script output, both from within SAM and from the PowerShell command prompt and post it here.