Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: LOG for Copy-item

$
0
0

thanks, I try some scenarios and not capable use this examples

I try something like

$computer = Get-Content C:\temp\computer.txt
 
foreach ($c in $computer) {
 
if (Test-Connection -ComputerName $c -Count 1 -Quiet ) 
{
Copy-Item C:\temp\AKANE.JPG -Destination \\$c\c$\ranma\ -ErrorAction SilentlyContinue -ErrorVariable copy_log
}
if ($copy_log) {Write-Output "On computer $c connection ok, but copy has fail" | out-file c:\temp\copy_log.txt
}
else
{ 
Write-Output "Computer $c is Offline" | Out-File C:\temp\connection_log.txt
}
}

The function copy its ok, but logs are going crazy.

its not working, is like -errorvariable put only the last computer on TXT logs.

thank you guys


Viewing all articles
Browse latest Browse all 13067

Trending Articles