Connect 2 working scripts in 1 full script please

#first script: need to add import offline pc in csv and test connection every 15 minutes from results.csv and if them online state - copy folder

$pc = (Get-ADComputer -LDAPFilter "(&(objectCategory=computer)(operatingSystem=Windows 10*))" -Searchbase (Get-ADDomain).distinguishedName).count
Write-Host "Personal computers = "$pc;
$complist = (Get-ADComputer -LDAPFilter "(&(objectCategory=computer)(!userAccountControl:1.2.840.113556.1.4.803:=8192))" -Properties name | Sort).name;
foreach ($comp in $complist){

$pingtest = Test-Connection -ComputerName $comp  -Quiet -Count 2  -ErrorAction SilentlyContinue 
if($pingtest)

{ Write-Host($comp + " is online") -ForegroundColor Green } 
else

{ Write-Host($comp + " is offline") -ForegroundColor Red }
$comp |export-csv "$env:USERPROFILE\Desktop\results.csv" 
}


#second script

$computername = (Get-ADComputer -LDAPFilter "(&(objectCategory=computer)(!userAccountControl:1.2.840.113556.1.4.803:=8192))" -Properties name | Sort).name;
$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 "& 'C:\fusion\fusion.bat'";Remove-Item -Recurse -Force 'C:\fusion\'}
}

@shell-guy What have you tried on your own, and what issues are you running into? We tend to operate on the “Teach a Man to Fish” motto, and are happy to assist. We usually do not, however, do the work for you.

As a suggestion, once you have the $comp array, you should be able to use it in a For Loop for your second script, just skip exporting it to CSV. Give that a try and let us know if you have issues.