Copy-Item
Copy a file or folder
Copy-Item -Path .\notes.txt -Destination .\backup\notes.txt
- Works on
- WindowsLinuxmacOS
- PowerShell
- 5.1 and later
- Reference
- Microsoft Learn: Copy-Item
- PowerShell 7 On Linux and macOS, cp runs the system command instead of this cmdlet. Type the full cmdlet name there.
Copies a file or folder. The destination can be a file name or a folder that already exists.
Use -Recurse for folders. Use -WhatIf first if you are unsure.
Try this
Copy-Item -Path .\docs -Destination .\docs-copy -Recurse -WhatIf
Coming from another shell
| Shell | What you might type |
|---|---|
| bash / zsh | cp notes.txt backup/ |
| cmd.exe | copy notes.txt backup\ |
More in From bash and From cmd.