Not able to run powershell script from autosys

0

I am new to powershell and using 1.0version and am trying to write a powershell script that I can execute using autosys scheduler. When the I run the command in autosys

powershell -command "& { %MY_HOME%\bin\TestScript.ps1 argument; exit $LASTEXITCODE }"

it gives me the error

script cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.

I did set the executionpolicy to unrestricted from an admin user account. Not sure how I should execute this so my autosys job runs this powershell script. I have also tried using just quotes. but everytime I get this error.

Thanks

psnewbie

Posted 2012-04-13T20:52:04.690

Reputation: 1

Did you run the set-executionpolicy from a Powershell window opened with "run QA administrator"? Check your current lever with get-... – None – 2012-04-13T21:37:23.480

Did you use one of the following commands? Set-ExecutionPolicy RemoteSigned or Set-ExecutionPolicy Unrestricted. – None – 2012-04-13T21:47:19.817

If you are trying to run a remote command, on the remote computer you must set also WinRM by running Set-WSManQuickConfig – None – 2012-04-13T21:52:31.900

Offtopic: it would be great if you could upgrade to PowerShell 2 (actually on Win Server 2008 R2 it should be by default 2.0). Seems that removing is a PS 2 feature http://www.simple-talk.com/sysadmin/powershell/powershell-version-2-what-is-new-and-why-is-it-important/

– None – 2012-04-13T21:57:39.880

Answers

0

My guess is that those scripts are run under a different account than the one you changed the execution policy for. Try to change the policy for all users on the machine by using the -Scope parameter:

Set-ExecutionPolicy RemoteSigned -Scope LocalMachine

zdan

Posted 2012-04-13T20:52:04.690

Reputation: 2 732

I'll try the scope, but am not sure if it is available in v1.0. – psnewbie – 2012-04-16T13:37:29.273

This did not work as I am in v1.0 – psnewbie – 2012-04-16T14:29:16.023

0

OOps, it's just a generic error, Google your error, you can find bundles of posts on the solution. This is just you havent enabled running Powershell scripts on your target machine.

Sandeep

Posted 2012-04-13T20:52:04.690

Reputation: 1