Merge pull request #1869 from seththoenen/fix-host-windows

Add warningaction to test-netconnection
This commit is contained in:
Adam Leff 2017-05-31 15:42:38 -04:00 committed by GitHub
commit b7cc6c31b7

View file

@ -148,7 +148,7 @@ module Inspec::Resources
def ping(hostname, port = nil, _proto = nil)
# ICMP: Test-NetConnection www.microsoft.com
# TCP and port: Test-NetConnection -ComputerName www.microsoft.com -RemotePort 80
request = "Test-NetConnection -ComputerName #{hostname}"
request = "Test-NetConnection -ComputerName #{hostname} -WarningAction SilentlyContinue"
request += " -RemotePort #{port}" unless port.nil?
request += '| Select-Object -Property ComputerName, TcpTestSucceeded, PingSucceeded | ConvertTo-Json'
cmd = inspec.command(request)