0
0
PowerShellscripting~10 mins

Copy-Item and Move-Item in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to copy a file from source to destination.

PowerShell
Copy-Item -Path 'C:\source\file.txt' -Destination [1]
Drag options to blanks, or click blank then click option'
A'C:\source\file2.txt'
B'C:\source\file.txt'
C'C:\backup\file.txt'
D'C:\backup\file2.txt'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same path for source and destination, which does nothing.
Forgetting to put the path in quotes.
2fill in blank
medium

Complete the code to move a file to a new folder.

PowerShell
Move-Item -Path 'C:\docs\report.docx' -Destination [1]
Drag options to blanks, or click blank then click option'
A'C:\archive\report2.docx'
B'C:\docs\report.docx'
C'C:\docs\report2.docx'
D'C:\archive\report.docx'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same path for source and destination.
Not specifying the filename in the destination path.
3fill in blank
hard

Fix the error in the code to copy all text files from one folder to another.

PowerShell
Copy-Item -Path 'C:\data\*.txt' -Destination [1] -Recurse
Drag options to blanks, or click blank then click option'
A'C:\backup'
B'C:\backup\'
C'C:\data\backup\'
D'C:\data\backup'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a destination path with trailing backslash causing errors.
Not specifying the destination folder correctly.
4fill in blank
hard

Fill both blanks to move all .log files from source to archive folder and overwrite existing files.

PowerShell
Move-Item -Path 'C:\logs\*.log' -Destination [1] -[2]
Drag options to blanks, or click blank then click option'
A'C:\archive\logs'
B'C:\logs\archive'
CForce
DRecurse
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong folder path for destination.
Forgetting to add the Force parameter to overwrite.
5fill in blank
hard

Fill all three blanks to copy all .csv files from source to backup folder, including subfolders, and preserve the directory structure.

PowerShell
Copy-Item -Path 'C:\data\*.csv' -Destination [1] -[2] -[3]
Drag options to blanks, or click blank then click option'
A'C:\backup\data'
BRecurse
CContainer
D'C:\data\backup'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using Recurse to copy subfolders.
Not using Container to preserve folder structure.