Get-Content c:\test\computers.txt | ForEach-Object
{
if(Test-Connection -ComputerName $_ -Quiet -Count 1) {
New-Object -TypeName PSCustomObject -Property @{
ComputerName = $_
'Ping Status' = 'Ok'
}
}
else
{
New-Object -TypeName PSCustomObject -Property @{
ComputerName = $_
'Ping Status' = 'Failed'
}
}
} | Export-Csv -Path c:\test\PingStatus.csv -NoTypeInformation
If you find this article useful please leave me a comment or click on an ad to show your support.
No comments :
Post a Comment