Forum Discussion

balubeto's avatar
balubeto
Brass Contributor
Oct 21, 2022

Problem with CopyItem cmdlet

Hi   I use PowerShell 7.x on Windows 11 Update.   I should copy all the txt files from the Test1 directory to the Test2 directory. I tried writing     Copy-Item -Path .\Test1\ -Filter *.txt ...
  • LainRobertson's avatar
    Oct 21, 2022

    balubeto 

     

    The source path requires a wildcard at the end as shown below. Without this wildcard, the command will copy the directory object only, not the child content.

     

    Copy-Item -Path .\Test1\* -Filter *.txt -Destination .\Test2\

     

    Cheers,

    Lain

Resources