Custom Scripts not working

Custom Scripts not working

I am trying to run a custom script in an automation policy. The script supposedly completed successfully but the script doesn't do what it's supposed to do. I am running it as update-userscript.ps1 %userName%  
Should I be using a different variable? 
The script runs flawlessly outside of manage engine. It does do a database query to an external server but the service account for manage engine has permissions so I don't think that's an issue.  

                New to ADSelfService Plus?