简体   繁体   中英

How to run Powershell file (having extension .ps1) using jmeter?

我在此图像中使用操作系统采样器

I want to execute.ps1 file in jmeter. I have pass the parameter as in image,but in output facing errors. The filename, directory name, or volume label syntax is incorrect. Though the filename, directory name are correct.

Here is your problem:

JMeter Powershell

Remove that quotation mark and everything should start working as expected

In general, you are making things overcomplicated.

  1. Why do you need these cmd /c ? Why just don't call powershell directly?
  2. Normally powershell is in Windows PATH, there is no need to provide full path to it

So configure your OS Process Sampler as:

  • Command: powershell
  • Parameter: D:\\Software\\apache=jmeter-3.0\\apache-jmeter-3.0\\bin\\TIP.ps1

JMeter好的OS流程采样器配置

See How to Run External Commands and Programs Locally and Remotely from JMeter article for more information on invoking 3rd-party processes from your JMeter test.

I know this is an old thread but since the response was not correct for me I found the solution to be this:

Using the OS Process Sampler you need to add as command powershell.exe and as variables exactly the following:

  • -executionpolicy
  • bypass
  • -file
  • fullpathToYourScript.ps1

Jmeter 调用 Powershell 示例

This worked perfectly fine for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM