0
0
PowerShellscripting~10 mins

VS Code with PowerShell extension - Interactive Code Practice

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

Complete the code to display the current date and time in PowerShell.

PowerShell
Get-Date | [1]
Drag options to blanks, or click blank then click option'
AGet-Content
BOut-File
CStart-Process
DWrite-Output
Attempts:
3 left
💡 Hint
Common Mistakes
Using Out-File writes to a file instead of showing output.
Using Start-Process starts a new process, not for output.
Using Get-Content reads from files, not for output.
2fill in blank
medium

Complete the code to list all running processes in PowerShell.

PowerShell
[1]
Drag options to blanks, or click blank then click option'
AGet-Process
BStart-Process
CGet-Service
DStop-Process
Attempts:
3 left
💡 Hint
Common Mistakes
Using Get-Service lists services, not processes.
Using Start-Process starts a new process, not lists them.
Using Stop-Process stops a process, not lists them.
3fill in blank
hard

Fix the error in the code to read the content of a file named 'log.txt'.

PowerShell
Get-Content [1]
Drag options to blanks, or click blank then click option'
A-File log.txt
Blog.txt
C-Path log.txt
DPath log.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Using -Path log.txt works but is not needed here.
Using -File log.txt is not a valid parameter.
Using Path log.txt causes syntax error.
4fill in blank
hard

Fill both blanks to filter processes with CPU usage greater than 100.

PowerShell
Get-Process | Where-Object { $_.CPU [1] [2] }
Drag options to blanks, or click blank then click option'
A>
B100
C<
D50
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' reverses the filter.
Using '50' instead of '100' changes the threshold.
5fill in blank
hard

Fill all three blanks to create a hashtable of process names and their IDs for processes using more than 50 CPU.

PowerShell
$result = @{}; foreach ($p in Get-Process | Where-Object { $_.CPU [3] 50 }) { $result[[1]] = [2] }
Drag options to blanks, or click blank then click option'
A$p.Name
B$p.Id
C>
D$p.CPU
Attempts:
3 left
💡 Hint
Common Mistakes
Using $p.Id as key and $p.Name as value swaps keys and values.
Using '<' instead of '>' changes the filter logic.
Using $p.CPU as key or value is incorrect.