question

DHoss-6479 avatar image
0 Votes"
DHoss-6479 asked DHoss-6479 answered

Sorted out put in file

HI All
I have script that does ping and get the information from hundreds of computer at the end, output to a csv file with the following commnad:

if ($ResolveNames) { $FormattedPingResults | Sort-Object SuccessPercentage | Select-Object NameInList, NameFromDNS, IPAddressListFromDNS, SuccessPercentage, LastPingStatus, PingedFrom | Export-Csv -Path $OutputPath -NoTypeInformation }
else { $FormattedPingResults | Sort-Object SuccessPercentage | Select-Object NameInList, SuccessPercentage | Export-Csv -Path $OutputPath -NoTypeInformation }

It is a very complex script for me as I am a novice but wondering at this end part, how can I create that csv file with the computer name which are only 100 success rate. It has option for success rate as 0 or 100.

I would appreciate in advance. I did not post the whole script as it is very long. Hope one of you will reply.

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered

Hi @DHoss-6479 ,

the Where-Object cmdlet could be helpful:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/where-object?view=powershell-7.1

To get started with the Where-Object it could look like this:

 ... | Where-Object {$_.SuccessPercentage -eq "100"}

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/where-object?view=powershell-7.1#example-1--get-stopped-services


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DHoss-6479 avatar image
0 Votes"
DHoss-6479 answered

Hi @AndresBaumgarten
Thanks for your reply but I found a different way of doing it. Thanks again.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.