I am trying to test a network connection and if it's good, tell me it is found. ELSE write-host it is not found, and export that computer to a CSV. However, I am just getting the error "Testing connection to computer failed: error due to lack of resources." on computers that cannot get a connection. Does test-connection not work this way? The = "True" is working for me. Below is my code:
foreach ($computer in $Computers)
$computername = $computer.Computers
$testConnection = Test-Connection $computername
IF ($testConnection = "True")
{
{
Write-Host "$computername found"
}
ElSE
{
Write-Host "$computername does not have CCleaner installed." #| Export-Csv C:\Users\jcheng\Desktop\Scripts\PingTestLog.txt -Append
}
{