Q: What's the proper way to run inspec under Windows?

NOTICE: Moved from GitHub: question: what's the proper way to run inspec under Windows? 路 Issue #3936 路 inspec/inspec 路 GitHub

:control_knobs: Description

question: what's the proper way to run inspec under Windows?
I'm getting the error at the Stacktrace section when I'm running inspec from powershell.

:earth_africa: InSpec and Platform Version

inspec --version
3.9.0

Windows 10

:thinking: Replication Case

run inspec from a powershell terminal

:computer: Stacktrace

inspec : Cannot process the XML from the 'Error' stream of 'c:\opscode\inspec\bin\inspec.bat': Root element is missing.
At C:\jenkins\workspace\windows\3_test.ps1:18 char:1

  • inspec exec .\tests\uninstall.rb --reporter cli junit:artifacts/test_ ...
  •   + CategoryInfo          : SyntaxError: (c:\opscode\inspec\bin\inspec.bat:String) [], XmlException
      + FullyQualifiedErrorId : ProcessStreamReader_CliXmlError

We'd need more information from the user, there's nothing fundamentally faulty with running inspec exec . --reporter cli junit:out.xml on Windows.

  • Does updating ChefDK (it looks like this is ChefDK InSpec rather than a gem) help?
  • Does the command work when run directly (and not part of the Jenkins script mentioned in the issue)?

The error looks maybe like some unhandled error is happening and InSpec isn't getting far enough to output XML?

Hi,
just to provide additional info about this error,...

I got exactly the same error message using PowerShell to invoke inspec.

I usually need to connect to a server with inspec so I need to use the param -t winrm://... and this error never happens.

But with my first script without -t parameter inspec generated this error.

Using the same script but adding -t parameter (just for testing because it is not required) the error message goes away.

Using the same script with and without -t parameter in a CMD console the error is not generated.

In all cases, the tests included in script are executed correctly an I get the required report.

This is the error message:

inspec : Cannot process the XML from the 'Error' stream of 'C:\***\inspec\bin\inspec.bat': Root element is missing.
At C:\***\durable-1eadfe49\powershellScript.ps1:1 char:1
+ inspec exec c:\***/cor ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SyntaxError: (C:\***\inspec\bin\inspec.bat:String) [], XmlException
    + FullyQualifiedErrorId : ProcessStreamReader_CliXmlError

Regards