Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

CSV ping formatting.

$
0
0

Ok.. so I am very new to PS. in fact this is my first script so bare with me.

What I am trying to do is run a script that will ping a list of devices if from a csv file, then output the results to another csv file.

My csv is two columns, Ip and description of device.

Ip,Device

192.168.192.168,location

issue is that when I run the job, it runs but adds the two columns together into one column.

 

"Register","Ping Status"
"IpAddress,Register","Failed"
"132.239.75.1,Revelle.Conf.Desk.1","Failed"
"132.239.75.16,Revelle.Conf.Desk.2","Failed"
"132.239.75.18,Revelle.Conf.Desk.3","Failed"
"132.239.75.12,Revelle.Conf.Desk.4","Failed"

If I remove the column "Register" the it runs fine and everything pings but since it is adding the two columns into one, it fails.

#

Get-ContentC:\Users\user\Desktop\ipCSV.csv|ForEach-Object {

if(Test-Connection-ComputerName$_-Quiet-Count 2) {

New-Object-TypeNamePSCustomObject-Property @{

Register=$_

'Ping Status'='Ok'

}

}else {

New-Object-TypeNamePSCustomObject-Property @{

Register=$_

'Ping Status'='Failed'

}

}

}|Export-CsvC:\Users\user\Desktop\POSPingStatus.csv-NoTypeInformation

 

 

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles