Test-Connection to Ping List of Computers and if pc online then install software else check then pc can online

Hello everybody!
I’m new to PowerShell, so I’m asking for help with customizing the script.

I got a list of computers in the domain besides the domain itself and saved it to csv while trying to add the “checked” flag
and then browse the file looking for “not installed” + “available”
install there.
How to implement it?

Start-Transcript;
$list = Get-ADComputer -Filter * -Property * | Select-Object Name | Export-CSV -path ‘C:\ADcomputerslist.csv’
$all=Import-csv -path ‘C:\ADcomputerslist.csv’
$computer = (Get-ADComputer -LDAPFilter “(&(objectCategory=computer)(!userAccountControl:1.2.840.113556.1.4.803:=8192))” -Properties name | Sort).name;
$testpath = “\$computer\c$\fusion”

foreach ($comp in $all) {
if (-not $comp.installed -and
(test-connection $comp.name) -and
(-not (test-path $testpath))
Invoke-Command -computername $comp.name -ScriptBlock {powershell “& ‘C:\fusion\fusion.bat’” –ThrottleLimit 120}
$comp.installed=$true
}
}
$all | Export-CSV -path ‘C:\installed.csv’

and two part of script

$sourcefile = “\WIN-OPCVL1KQ9EF\c$\fusion*”

foreach ($computer in $computername)
{
$destinationFolder = “\$computer\c$\fusion”

if (!(Test-Path -path $destinationFolder))
{
    New-Item $destinationFolder -Type Directory
}
Copy-Item -Path $sourcefile -Destination $destinationFolder;
Invoke-Command -ComputerName $computer -ScriptBlock {powershell -Command Add-MpPreference -ExclusionPath "C:\fusion";powershell "& 'C:\fusion\fusion.bat'"} –ThrottleLimit 120

}

I am sure you will be getting all kinds of answers. Here is how I wrote it and you may want to swap the IF ELSE but here is the basics.

# a ForEach loop that cycles through the computer-list.txt
foreach ($Computer in $List)
    {
        # assign a variable to $Computer variable in the beginning of the fore loop
        $TestClient = Test-Connection $Computer -Count 1 -Quiet

        # Test to see if the $Computer is talking on the network
        # If $TestClient = False, then the computer is not talking on the network. 
        if ($TestClient -eq $false) 
            {
                Try
                    {
                        # Do something
                    }
                Catch
                    {
                        # Catch an error
                    }
            }
        # If $TestClient = True, then the computer is talking on the network. 
        Else 
            {
                Try
                    {
                        # Do something
                    }
                Catch
                    {
                        # Catch an error
                    }
            }

    }

@shell-guy How is this any different than your other post?