So I wrote the following code to get txt files, pipe it, and then copy them to a destination.
Get-ChildItem -Path "C:\Source" -Recurse | Where {$_.FullName -Like '*.txt*'} | Copy-Item $_.FullName -Destination "C:\Destination"
The problem is that the script would not work this way, so I kept looking around and found an example of a script similar to mine but they use % and {} brackets at the copy-item command. I’m trying to understand what the difference means.
Get-ChildItem -Path "C:\Source" -Recurse | Where {$_.FullName -Like '*.txt*'} | % {Copy-Item $_.FullName -Destination "C:\Destination"}