class WindowsPorts
@see connect.microsoft.com/PowerShell/feedback/details/1349420/get-nettcpconnection-does-not-show-processid<br>TODO: double-check output with ‘netstat -ano’
TODO: Get-NetTCPConnection does not return PIDs
TODO: currently Windows only supports tcp ports
TODO: Add UDP infromation Get-NetUDPEndpoint
def info
def info # get all port information cmd = inspec.command('Get-NetTCPConnection | Select-Object -Property State, Caption, Description, LocalAddress, LocalPort, RemoteAddress, RemotePort, DisplayName, Status | ConvertTo-Json') begin ports = JSON.parse(cmd.stdout) rescue JSON::ParserError => _e return nil end return nil if ports.nil? ports.map { |x| { port: x['LocalPort'], address: x['LocalAddress'], protocol: 'tcp', process: nil, pid: nil, } } end