Hi all,
I would like to write a one-liner to scan a host for a list of predefined ports and then output that to a csv so I can import to excel and then manipulate the data. From the console the below works fine (without the export-csv), but when when I export it to excel the output is screwed. I also tried out-file and had similar results. you may recognise the ports, they are the ports required for vmware virtual centre. Thanks in advance.
$ports = “80”,”88”,”389”,”443”,”902”,”903”,”1234”,”1235”,”2012”,”2013”,”2014”,”8080”,”8085”,”8089”,”8443”,”60099”,”6501”,”6502”,”7005”,”7009”,”7080”,”7331”,”7343”,”7444”,”8000”,”8009”,”8100”,”8182”,”8200”,”9000”,”9001”,”9002”,”9003”,”9004”,”9005”,”9006”,”9007”,”9008”,”9009”,”9010”,”9443”,”9875”,”9876”,”9877”,”9090”,”10080”,”10111”,”10443”,”11711”,”11712”,”12721”,”8190”,”8191”,”22000”,”22100”,”31010”,”31100”,”32010”,”32100”,”12443” foreach($port in $ports){ Test-NetConnection -ComputerName 'the computer I was to port scan' -port $port | export-csv -notypeinformation 'pathtothefiletoexprot' }