Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to get the last 5 entries from the Application event log.
PowerShell
Get-EventLog -LogName Application -Newest [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number other than 5 for the -Newest parameter.
Omitting the -Newest parameter and getting all entries.
✗ Incorrect
The -Newest parameter specifies how many recent entries to retrieve. Here, 5 entries are requested.
2fill in blank
mediumComplete the code to filter event log entries with EntryType 'Error'.
PowerShell
Get-EventLog -LogName System | Where-Object { $_.EntryType -eq '[1]' } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Warning' or 'Information' instead of 'Error'.
Forgetting to quote the string 'Error'.
✗ Incorrect
The EntryType property filters events by type. 'Error' selects error events.
3fill in blank
hardFix the error in the code to get event logs from the Security log.
PowerShell
Get-EventLog -LogName [1] -Newest 10
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'security' with lowercase s (PowerShell is case-insensitive but best to use correct casing).
Using 'System' or 'Application' instead of 'Security'.
✗ Incorrect
The Security log is named 'Security'. Using the correct log name avoids errors.
4fill in blank
hardFill both blanks to get the count of Error entries in the System log.
PowerShell
$count = (Get-EventLog -LogName [1] | Where-Object { $_.EntryType -eq '[2]' }).Count
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up log names and entry types.
Using 'Warning' instead of 'Error'.
✗ Incorrect
We want to count Error entries in the System log, so use 'System' and 'Error'.
5fill in blank
hardFill all three blanks to create a hashtable of event counts by EntryType from the Application log.
PowerShell
$counts = @{ [1] = (Get-EventLog -LogName Application -EntryType Error).Count; [2] = (Get-EventLog -LogName Application -EntryType Warning).Count; [3] = (Get-EventLog -LogName Application -EntryType Information).Count } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Application' as a key instead of an EntryType.
Mixing up the order of keys.
✗ Incorrect
The hashtable keys should be the EntryType names: 'Error', 'Warning', and 'Information'.