A couple of things:
- You can use the -filter parameter to search for the particular folder
- Pipe the results of your get-childitem so that it only tries to do a copy-item when it finds a folder
Use the FullName property when using the -recurse parameter on get-childitem to ensure the full path to the item is always used
Import-CSV -Delim ',' -Path $filePath | ForEach-Object { Get-ChildItem -Path D:\Folder\$InstanceName -Recurse -Directory -Filter $_.FOLDERNAME | ForEach-Object { Copy-Item $_.FullName d:\CopyFolder\$InstanceName -Recurse } }