• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

PowerShell Quetion.

yugpatel

Senior member
I am trying to copy all .pdf files from all folders and sub folder (dirs. and subdirs).
First I used

$source = "c:\Folder1\"
$desti = "D:\foderA\"
PS> Get-ChildItem -recurse $source -Filter "*.pdf"

It displays all the files for dir and sub dir but when I try to use copy-Item I get error.

PS> Get-ChildItem -recurse $source -Filter "*.pdf" | % {Copy-Item $_ -destination $desti}
Error: Copy-Item : Cannot find path 'H:\Folder1\Folder2\..\.. because it does not exist

What am I doing wrong?
 
Last edited:
Your pipeline input is missing the property fullname... rest of your code is fine...

Get-ChildItem -recurse $source -Filter "*.pdf" | % {Copy-Item $_.fullname -destination $desti}
 
Back
Top