0
0
PowerShellscripting~20 mins

Why automation saves time in PowerShell - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Automation Time Saver Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this PowerShell script?
This script measures how long it takes to run a loop 5 times. What will it print?
PowerShell
Measure-Command {for ($i=1; $i -le 5; $i++) {Start-Sleep -Seconds 1}} | Select-Object TotalSeconds
A
TotalSeconds
-----------
5.0
B
TotalSeconds
-----------
1.0
C
TotalSeconds
-----------
10.0
D
TotalSeconds
-----------
0
Attempts:
2 left
💡 Hint
Think about how long each loop iteration sleeps.
🧠 Conceptual
intermediate
1:30remaining
Why does automation save time in repetitive tasks?
Choose the best reason why automation helps save time when doing repetitive tasks.
AAutomation increases the chance of human error.
BAutomation makes tasks more complicated and slower.
CAutomation requires manual input for every step.
DAutomation runs tasks faster and without breaks, reducing total time.
Attempts:
2 left
💡 Hint
Think about how machines work compared to humans.
🔧 Debug
advanced
2:30remaining
Identify the error in this PowerShell automation script
This script is supposed to rename all .txt files to .bak files in a folder. What error will it cause?
PowerShell
Get-ChildItem -Path . -Filter *.txt | Rename-Item -NewName { $_.Name -replace '.txt', '.bak' }
ARename-Item fails because -NewName script block returns string incorrectly.
BNo error, script runs successfully renaming files.
CGet-ChildItem fails due to wrong filter syntax.
DRename-Item fails because $_ is not recognized inside script block.
Attempts:
2 left
💡 Hint
Check how Rename-Item uses script blocks for -NewName.
🚀 Application
advanced
2:30remaining
How does this automation script save time?
This script backs up a folder every day automatically. How does it save time compared to manual backup?
PowerShell
if (-not (Test-Path C:\Backup)) { New-Item -ItemType Directory -Path C:\Backup }
Copy-Item -Path C:\Data\* -Destination C:\Backup -Recurse
AIt runs automatically without user needing to remember or do steps manually.
BIt slows down backup by copying files one by one.
CIt requires user to start it manually every time.
DIt deletes original files after copying.
Attempts:
2 left
💡 Hint
Think about what automation means for repetitive tasks.
📝 Syntax
expert
3:00remaining
Which PowerShell command correctly automates deleting files older than 30 days?
Select the command that deletes files older than 30 days in C:\Logs folder.
AGet-ChildItem C:\Logs | Remove-Item { $_.LastWriteTime -lt (Get-Date).AddDays(-30) }
BGet-ChildItem C:\Logs | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-30) } | Remove-Item
CGet-ChildItem C:\Logs | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-30) } | Remove-Item
DRemove-Item C:\Logs -Filter { $_.LastWriteTime -lt (Get-Date).AddDays(-30) }
Attempts:
2 left
💡 Hint
Files older than 30 days have LastWriteTime less than today minus 30 days.