I am trying to grab certain logs from a folder and copy them to my device. The code works, but the output is not what I expect (the other three log files are in the Logs folder). I would just like to have my three files appear. The output I get it below. The console complains about the directory already existing, but that is because it is created prior to my loop I think?
$filename = $env:COMPUTERNAME
$files = @('CAS.log', 'LocationServices.log', 'AppDiscovery.log', 'CCMExec.log')
foreach ($file in $files)
{
Copy-Item "c:WindowsCCMLogs" -Filter $file -Destination
"\REMOTECOMPUTERNAMEc$RemoteLogStore$filename" -Recurse
}
question from:https://stackoverflow.com/questions/65888144/powershell-recursively-writing-to-the-same-directory