Forum Discussion

xxlyyk's avatar
New Contributor
3 years ago

powershell from groovy no longer working

We have a powershell script to get something from a msmq queue. This used to run fine before readyapi 3.10 (I'm not totally sure which the latest version was that we tried before that(, but in 3.10 en 3.20 the script no longer runs. Also other script no longer work.  For example creating a simple folder.


import java.lang.String

def powerShellCommand ='New-Item -Path \'C:\\JSONJournal\' -Name \'tests\' -ItemType \'directory\''
def shellCommand = "powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command \"${powerShellCommand}\""
def process = shellCommand.execute()

2 Replies

  • TNeuschwanger's avatar
    Champion Level 2

    Hello xxlyyk 


    You need to help us help you...  "no longer working" does not help us to solve your issue...  Are you getting an error code response now that you didn't before?  Is the error code different than it used to be?  Is the directory not created when you run your script?  What indicates to us that it is not working?


    I took the code you provided and ran it in SoapUI 5.6.0 and ReadyAPI 3.20.0...  Both versions returned exit value of 0.  SoapUI created the directory while ReadyAPI didn't.  Since you have a Powershell layer it is hard to debug why that might be the case and adds complexity to a simple operation.


    My recommendation is to un-complicate your world and use the ReadyAPI features for handling JMS (message queues).  Eliminate PS as a dependency and do what you can using the built in Groovy.  The 8 lines of PS code you presented as a sample is easily reduced to 1 line in a Groovy test step:

    new File('C:\\JSONJournal\\tests\\').mkdirs();


    Complexity becomes expensive when you have to resort to debugging and whoever has to maintain that complexity in the future when you pass it along to the next person.




    • xxlyyk's avatar
      New Contributor
      Well you exactly recreated the behaviour I got, directory got created in
      old version and not in the new version. No error code, nothing. So
      basically you are confirming that this is a bug and not something weird in
      my environment (we reproduced the error in multiple of our own

      As for your suggestion to using jms, I don't think there is a way to
      directly access msmq through JMS. I think there used to be support through
      hermes, but that's deprecated.

      And of course the sample code was not the code I actually want fixed. Our
      actual code calls a powershell script with multiple parameters. The script
      searches a queue based on several criteria and saves a found message on
      file. But since that script is not the problem I thought I'd give a simpler
      example with the same behaviour to not distract from what I think is the
      actual issue.