PowerShell: Copy a File or Folder

Need to copy a file or folder to another location - backing up before an edit, duplicating a template, or moving files as part of a script? This one-liner copies it directly from the terminal.

Prerequisites:

  • Privileges: None
  • Module: Built-in, no import needed

Quick Command:

Copy-Item -Path "C:\SourceFolder" -Destination "C:\DestinationFolder"
📦
Want all of them at once?
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.

How It Works:

  • Copy-Item copies the item at the specified path to a new location - it works on both files and folders
  • -Path "C:\SourceFolder" points to what you want to copy - replace this with the actual file or folder you're copying.
  • -Destination "C:\DestinationFolder" sets where the copy should be placed.

Pro Tip:

If the source is a folder containing subfolders and files, add -Recurse to copy everything inside it, not just the top-level folder itself:

Copy-Item -Path "C:\SourceFolder" -Destination "C:\DestinationFolder" -Recurse