What does the PowerShell cmdlet <code>Copy-Item</code> do?
It copies files or folders from one location to another, similar to copying a file on your computer.
Click to reveal answer
beginner
What is the difference between Copy-Item and Move-Item?
Copy-Item duplicates the file or folder, leaving the original intact. Move-Item transfers the file or folder to a new location and removes it from the original place.
Click to reveal answer
beginner
How do you copy a file named report.txt from C:\Docs to D:\Backup using PowerShell?
Use the command: Copy-Item -Path 'C:\Docs\report.txt' -Destination 'D:\Backup'
Click to reveal answer
intermediate
What happens if you use Move-Item to move a file to a folder that already has a file with the same name?
PowerShell will overwrite the existing file without warning, replacing it with the moved file.
Click to reveal answer
intermediate
How can you copy all files from one folder to another, including subfolders, using Copy-Item?
Use the -Recurse parameter: Copy-Item -Path 'C:\SourceFolder\*' -Destination 'D:\TargetFolder' -Recurse
Click to reveal answer
What parameter do you use with Copy-Item to include all subfolders?
A-Recurse
B-IncludeSubfolders
C-All
D-Subdirs
✗ Incorrect
The -Recurse parameter tells PowerShell to copy all files and folders inside subfolders.
Which cmdlet would you use to move a file instead of copying it?
AMove-Item
BCopy-Item
CRename-Item
DRemove-Item
✗ Incorrect
Move-Item moves files or folders to a new location, removing them from the original place.
If you want to copy a file but keep the original, which cmdlet should you use?
AMove-Item
BRemove-Item
CCopy-Item
DRename-Item
✗ Incorrect
Copy-Item duplicates the file, so the original stays where it is.
What happens if you move a file to a location where a file with the same name exists?
APowerShell asks for confirmation
BThe existing file is overwritten
CThe move fails with an error
DThe file is renamed automatically
✗ Incorrect
By default, Move-Item overwrites files with the same name without asking.
How do you specify the source file in Copy-Item?
A-Source
B-File
C-From
D-Path
✗ Incorrect
The -Path parameter specifies the file or folder to copy.
Explain how to copy a folder and all its contents to a new location using PowerShell.
Think about copying everything inside the folder, not just the folder itself.
You got /4 concepts.
Describe the difference between copying and moving files in PowerShell and when you might use each.
Consider what happens to the original file in each case.
You got /4 concepts.
Practice
(1/5)
1. What does the PowerShell command Copy-Item do?
easy
A. Duplicates files or folders to a new location without removing the original
B. Deletes files or folders permanently
C. Moves files or folders to a new location and deletes the original
D. Renames files or folders in the current location
Solution
Step 1: Understand the purpose of Copy-Item
Copy-Item creates a copy of the specified file or folder at a new location, leaving the original intact.
Step 2: Compare with other commands
Unlike Move-Item, Copy-Item does not remove the original file or folder.
Final Answer:
Duplicates files or folders to a new location without removing the original -> Option A
Quick Check:
Copy-Item = Duplicate without deleting original [OK]
Hint: Copy-Item duplicates; Move-Item moves and deletes original [OK]
Common Mistakes:
Confusing Copy-Item with Move-Item
Thinking Copy-Item deletes the original file
Assuming Copy-Item renames files
2. Which of the following is the correct syntax to move a file named report.txt from C:\Docs to D:\Backup in PowerShell?
easy
A. Copy-Item -Source 'C:\Docs\report.txt' -Target 'D:\Backup'
B. Move-Item -Path 'C:\Docs\report.txt' -Destination 'D:\Backup'
C. Move-Item -Source 'C:\Docs\report.txt' -Target 'D:\Backup' -Force
D. Copy-Item -Path 'C:\Docs\report.txt' -Destination 'D:\Backup'
Solution
Step 1: Identify the correct command for moving files
Move-Item is used to move files; Copy-Item copies files.
Step 2: Check the correct parameter names
Move-Item uses -Path for source and -Destination for target location.
Final Answer:
Move-Item -Path 'C:\Docs\report.txt' -Destination 'D:\Backup' -> Option B
Quick Check:
Move-Item syntax = -Path and -Destination [OK]
Hint: Use Move-Item with -Path and -Destination to move files [OK]
Common Mistakes:
Using Copy-Item instead of Move-Item to move files
Using incorrect parameter names like -Source or -Target
Omitting quotes around paths with backslashes
3. What will be the result of running this PowerShell code?
A. The destination path includes the filename, causing a conflict
B. Move-Item cannot move files between drives
C. Move-Item requires the -Force parameter to work
D. The source file does not exist or path is incorrect
Solution
Step 1: Check if source file exists
Move-Item fails if the source file path is wrong or file missing.
Step 2: Understand destination path usage
Destination can include filename; this is valid and not an error cause.
Final Answer:
The source file does not exist or path is incorrect -> Option D
Quick Check:
Missing source file causes Move-Item error [OK]
Hint: Verify source file exists before moving [OK]
Common Mistakes:
Assuming destination filename causes error
Thinking Move-Item can't move across drives
Believing -Force is always required
5. You want to move all .log files from C:\Logs to D:\OldLogs, but keep a copy of the latest log file in C:\Logs. Which PowerShell commands achieve this?