I have a CSV with 98 system names, each system has a file I need. They're all in the same folder on each machine, but the file name is unique.
I'd like to use copy-item to copy the file to a location on my local computer.
$AutoCADs = Import-csv "C:\DTS\BMC\AutoCAD - ANY VERSION_Members.csv"
$AutoPaths = "\\" + $AutoCADs + "\C$\DTS\BMC\Autodesk Audit\Information\*"
foreach-object{Copy-Item $AutoPaths -Destination "C:\DTS\BMC\Audit Results" -Force -Recurse}
When I run this, I get an error for each of the 98 machines. Each error looks like this:
Copy-Item : Cannot find path 'C:\Users\\@{D113978=Y118834}' because it does not exist. At \\CopyAuditFiles.ps1:3 char:16 + ... each-object{Copy-Item $AutoPaths -Destination "C:\DTS\BMC\Audit Resul ...
The @{D113978=Y118834} is confusing to me because each error has a similar string. D113978 is the first system name in the CSV.
The other system name (Y118834 in this example) changes for every error, with the first error having the second item in the csv, 2nd error having the 3rd item in the CSV etc.
So the script appears to be seeing each system name, but it's not doing what I want with the system name at all.
Can someone point out my flaw?