Copy

Commands

Copy-Item src.txt dst.txt

Copy a file (cp, copy, cpi)

Copy-Item -Path file.txt -Destination file.txt

Copy

cp C:\source\file.txt C:\destination\file.txt

Alias for Copy-Item

copy C:\source\file.txt C:\destination\file.txt

Copy using CMD.

robocopy C:\source C:\destination file.txt /E

Recursive copy (/E).

type C:\path\to\file.txt | clip

Copies content to clipboard.

Copies files or directory trees to another location, with options for:

copying empty directories (/E)

assuming destination is a directory (/I)

including hidden and system files (/H)

xcopy C:\source\file.txt C:\destination\file.txt /E /I /H

Copies a file from one location to another using .NET framework in PowerShell, with $true indicating overwrite if the destination file exists.

[System.IO.File]::Copy("C:\source\file.txt", "C:\destination\file.txt", $true)

Merges the content of two files into a third file.

copy C:\path\to\file1.txt + C:\path\to\file2.txt C:\path\to\mergedfile.txt

Clipboard Ops

Get-Clipboard

Get clipboard contents

type C:\path\to\file.txt | clip

Copies file content to clipboard.

Get-Content C:\path\to\file.txt | Set-Clipboard

Copies file content to clipboard.

"Some text" | Set-Clipboard

Copies text to clipboard

Get-ChildItem C:\path\to\directory | Set-Clipboard

Copies file listing to clipboard.

Copy SAM and System Hive

Backup SAM and SYSTEM hashes:

reg save hklm\system C:\system.hive
reg save hklm\sam C:\sam.hive

Last updated

Was this helpful?