Powershell script needs "warm up" to run from java code

Hi all,

I need to run ps scripts from my java code in order to set performance monitor counters value.
For that I use the following line:



Hi Tal,

You may find that the execution policy is preventing you from running the script from within java.
Try setting your execution policy to unrestricted in your profile and have another go.



Hi Tal,

You may find that the execution policy is preventing you from running the script from within java.
Try setting your execution policy to unrestricted in your profile and have another go.



Hi Guy,

I tried your proposal.



Hang on, did you run it in an Admin powershell locally? or did you update the PS1 script call?

That error tells me you probably updated the script to something like this:final String PS_COMMAND = "Powershell.exe set-executionpolicy Unrestricted -File .\myscript.ps1";

That would be incorrect as you are calling the set-executionpolicy cmdlet which has no -file argument. try this instead



ScreenHunter-02-Jul.-16-16.13.jpg 57 KB



Yup, That's incorrect. I just did what I told you not to do... lol - I forgot to remove the "set-"

Updated

Share this

Related Posts

There was an error in this gadget