Bird
0
0

You want to detect configuration drift on multiple servers by comparing their current state to a baseline stored in JSON files. Which approach best automates this in PowerShell?

hard📝 Application Q8 of 15
PowerShell - Automation Patterns
You want to detect configuration drift on multiple servers by comparing their current state to a baseline stored in JSON files. Which approach best automates this in PowerShell?
AUse Start-Process to open JSON files in Notepad for manual review
BManually open each JSON file and visually compare contents
CUse Invoke-Command to run Compare-Object remotely without reading files
DUse Get-Content to read JSON baseline and current files, convert with ConvertFrom-Json, then Compare-Object
Step-by-Step Solution
Solution:
  1. Step 1: Understand automation needs

    Automating drift detection requires reading baseline and current states programmatically.
  2. Step 2: Evaluate options for automation

    Use Get-Content to read JSON baseline and current files, convert with ConvertFrom-Json, then Compare-Object reads JSON files, converts them to objects, and compares them automatically.
  3. Step 3: Eliminate manual or incomplete options

    Options A and B are manual; C lacks reading baseline files.
  4. Final Answer:

    Use Get-Content to read JSON baseline and current files, convert with ConvertFrom-Json, then Compare-Object -> Option D
  5. Quick Check:

    Automate with JSON read, convert, compare = D [OK]
Quick Trick: Convert JSON to objects before comparing for automation [OK]
Common Mistakes:
  • Trying manual comparison for automation
  • Skipping JSON conversion step
  • Assuming remote Compare-Object works without data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes