Bird
0
0

Consider this script snippet:

medium📝 Command Output Q5 of 15
PowerShell - Automation Patterns
Consider this script snippet:
$mem = Get-Counter '\Memory\Available MBytes' -SampleInterval 1 -MaxSamples 1;$available = $mem.CounterSamples.CookedValue;if ($available -lt 500) { Send-MailMessage -To 'ops@example.com' -Subject 'Low Memory' -Body "Available memory is $available MB" -SmtpServer 'smtp.example.com' }

What will this script do when available memory is 450 MB?
ASend an email alert indicating low available memory
BIgnore the condition and do nothing
CRestart the system automatically
DLog the memory value to a file without sending email
Step-by-Step Solution
Solution:
  1. Step 1: Check the memory value

    The script checks if available memory is less than 500 MB.
  2. Step 2: Evaluate the condition

    450 MB is less than 500 MB, so the condition is true.
  3. Step 3: Action taken

    The script sends an email alert with the memory value.
  4. Final Answer:

    Send an email alert indicating low available memory -> Option A
  5. Quick Check:

    Memory below threshold triggers email [OK]
Quick Trick: Memory below threshold triggers email alert [OK]
Common Mistakes:
  • Assuming the script restarts the system
  • Thinking it logs instead of emailing
  • Believing it ignores low memory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes