Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warningaction to test-netconnection #1869

Merged
merged 1 commit into from
May 31, 2017
Merged

Add warningaction to test-netconnection #1869

merged 1 commit into from
May 31, 2017

Conversation

seththoenen
Copy link
Contributor

Signed-off-by: Seth Thoenen seththoenen@gmail.com

If you audit a Windows machine with the host resource and the ping test fails, there will be a warning message printed to the console similar to this:

WARNING: Ping to 1.2.3.4 failed -- Status: TimedOut
{
    "ComputerName":  "1.2.3.4",
    "TcpTestSucceeded":  true,
    "PingSucceeded":  false
}

When this standard output is parsed into JSON on line 157, it fails since the WARNING message isn't valid JSON. Appending a -WarningAction SilentlyContinue to the Test-NetConnection command eliminates the warning message and then the output is valid JSON and can be parsed successfully.

Signed-off-by: Seth Thoenen <seththoenen@gmail.com>
Copy link
Contributor

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching this one @seththoenen

@chris-rock chris-rock added the Type: Bug Feature not working as expected label May 30, 2017
Copy link
Contributor

@adamleff adamleff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @seththoenen! Great fix.

@adamleff adamleff merged commit b7cc6c3 into inspec:master May 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Feature not working as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants