Hey guys
Have a little problem.
Here's my code:
$datei = Get-content C:\Users\Dario\Desktop\Powershell\bla.csv
$Date = get-date -format d
$Time = get-date -format T
$a = 0
$datei | Foreach-Object {
$a++;
$ip = $_
$qry = ('select statuscode from win32_pingstatus where
address="' + $ip + '"')
$rslt = gwmi –query “$qry”
if ($rslt.StatusCode –eq 0) {
write-host "+" $ip
}
else {
$datei2 = "C:\Users\Dario\Desktop\Powershell
\FAIL\$Date.txt"
$Time + " | "+$ip | Add-content $datei2
write-host "-" $ip
}
$rslt = $null
}
My CSV-File looks so:
192.168.1.1
192.168.1.2
192.168.1.3
With this two files my programm works, but i want that my CSV-File looks like this:
192.168.1.1, Text1
192.168.1.2, Text2
192.168.1.3, Text3
How i must change my source, that when an ip isn't accessible, he only print the text out.
PS: Sry for my very bad english. I'm from switzerland and my notes in english are fucked up.
Thanks
Sylnois