Hi Guys,
I am need of some help related to powershell execetion from dynamics ax. i have created a powershell script that is runing perfect fine. i am now calling that script from dynamics ax using .net classes. i am facing any error when the powershell window get open and it tries to execute the powershell script in it.
File C:\test\test.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.
At line:1 char:17+ c:\test\test.ps1 <<<< + CategoryInfo : NotSpecified: (:) [], PSSecurityException + FullyQualifiedErrorId : RuntimeException
i google it, and i found it is something related to execution policy and scope which is currently as restricted on my windows 2008 server and scope is undefined.
My question here is that how i can modify my script to add some logic or script that enable powershell script execution in unrestricted mode and i do not get this error.
i am pasting my simple powershell script also
Set-ExecutionPolicy –Scope Process Unrestricted
$filelocation = dir c:\
$filename = "Archive.zip"
$shell_app=new-object -com shell.application
$zip_file= $shell_app.namespace("c:\$filename")
$destination=$shell_app.namespace("c:\")
$destination.copyhere($zip_file.items())
I apreciate any help here.