Can run the scanner from command prompt, but not in a PowerShell script

Hello,

After creating a sonar-project.properties file with this entry:

sonar.sources=E:/agents/SonarQube/_work/1/s

I am able to go to that directory and run sonar-scanner from the command prompt.

However, when I add the following to my release pipeline as a PowerShell task:

Set-Location E:\agents\SonarQube_work\1\s
sonar-scanner

It doesn’t work, and I get:

sonar-scanner : WARNING: An illegal reflective access operation has occurred
At E:\agents\Release_work_temp\faad5e8b-d1f3-44dd-9666-b5ee4a22e46f.ps1:3 char:1

  • sonar-scanner
  •   + CategoryInfo          : NotSpecified: (WARNING: An ill...on has occurred:String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
    
    

PowerShell exited with code ‘1’

How can I reproduce the successful experience running from command prompt in this PowerShell task?

Thank you,

Anatoly

It sounds to me, that sonar-scanner command cannot be found. Check PATH variable on you CI.