PoshTip #17 – Copy files to a new location
To copy a file from one folder to another, you can use the Copy-Item cmdlet :
Copy-Item -Path C:\folder1\file1.txt -Destination c:\folder2\file1.txt
You can copy and rename the file with the same cmdlet :
Copy-Item -Path C:\folder1\file1.txt -Destination c:\folder2\file1-renamed.txt
You can test if the destination folder exist with Test-Path cmdlet :
C:\> Test-Path C:\folder1\ True C:\> Test-Path C:\folder2\ True C:\> Test-Path C:\folder3\ False