Hi,
Even If I set the PowerShell Execution policy to Unrestricted, when I try to launch a script from a Commad line step added in SRM, the script is not executed. In the SRM log I can find:
[#2] dynamicType = <unset>,
[#2] faultCause = (vmodl.MethodFault) null,
[#2] result = (dr.secondary.CalloutResult) {
[#2] dynamicType = <unset>,
[#2] commandLine = "c:\windows\system32\cmd.exe /c C:\Source_code_VMware\Scripts\redirect.bat C:\CACINTEL\Source_code_VMware\Scripts\DRSrules_TEST.ps1",
[#2] output = "File C:\Source_code_VMware\Scripts\DRSrules_TEST.ps1 cannot be loaded
[#2] because the execution of scripts is disabled on this system. Please see "get-he
[#2] lp about_signing" for more details.
[#2] At line:1 char:2
[#2] + & <<<< 'C:\\Source_code_VMware\\Scripts\\DRSrules_TEST.ps1'
[#2] + CategoryInfo : NotSpecified: (:) [], PSSecurityException
[#2] + FullyQualifiedErrorId : RuntimeException
[#2]
[#2] ",
[#2] returnValue = 1,
[#2] },
[#2] msg = "",
Once again, the Execution policy is set to Unrestricted:
[vSphere PowerCLI] C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-ExecutionPolicy -list
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Unrestricted
Obviously the command works fine if I launch it manualy from a command prompt...
Any idea?
Thanks by advance
Make sure you set it in the 32bit version of PowerShell, SRM uses the 32 bit PowerShell host.
Thats the one that always gets me !
You need to check which account your SRM service is running under, if its left to default it will be system, the powershell script is run under the context of the user which runs the SRM service by default.
You may need to change the service to run as a service account and then log in with this account to set the execution policy before running the script.
I already changed the SRM service to use a "Service Account".
The Powershell policy has been set when logged using this service account......
Make sure you set it in the 32bit version of PowerShell, SRM uses the 32 bit PowerShell host.
Thats the one that always gets me !
Alan,
As always, you are the man !
Obviously I went into the trap and was setting the policy in the 64bit PowerCli session.
I even configured the Policy to RemoteSigned for a "better" security.
Thanks again for your extremly quick answer Alan.
what is the solution for this error?
I am also having same issue and my question is posted at :-
In the guest OS, under the SRM account, run
Set-ExecutionPolicy RemoteSigned
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The exeuction poliy i have manually set it to unrestricted in both the SRM servers.