Hi @lee roberts ,
could you please try this (not tested by myself):
$csv = Import-Csv "C:\temp\computers.csv"
$Source = "\\server1\FileToCopy.exe"
$dest = "C:\temp\"
$Output = "C:\temp\missingworkstations.csv"
$items = @()
#reads .csv for workstation NAME.
foreach ($line in $csv) {
#pings each Host. If true, Copy file.
if (Test-Connection $line.Name -count 1 -quiet) {
write-Host "true", $line.Name
$name = "\\" + $line.Name
#copies the file over to target machine
Copy-Item -path $Source -Destination $dest
}
#if ping fails, log which workstation and that workstation's IP in a new CSV.
else {
write-host "false" $line.Name $line.IP
$items += New-Object psobject -Property @{IP=$line.IP; Name=$line.Name}
}
}
#exports array of workstations that were unreachable for manual processing at a later date.
$items | Export-Csv -NoTypeInformation -Path $Output
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten