Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Configuration Drift Detection
📖 Scenario: You are a system administrator managing servers. You want to detect if any server's configuration has changed from the expected settings. This helps keep servers secure and consistent.
🎯 Goal: Create a PowerShell script that stores expected server configurations, sets a threshold for allowed differences, compares actual configurations to expected ones, and outputs any detected configuration drift.
📋 What You'll Learn
Create a dictionary of server names and their expected configuration values.
Add a threshold variable to define allowed difference count.
Write a loop to compare actual server configurations to expected ones and detect drift.
Print the list of servers with configuration drift.
💡 Why This Matters
🌍 Real World
System administrators use configuration drift detection to keep servers consistent and secure by spotting unexpected changes quickly.
💼 Career
This skill helps in roles like system administration, DevOps, and IT security where automation scripts maintain infrastructure health.
Progress0 / 4 steps
1
Create expected server configurations
Create a PowerShell hashtable called $expectedConfigs with these exact entries: 'ServerA' = 'v1.2', 'ServerB' = 'v1.3', 'ServerC' = 'v1.2'.
PowerShell
Hint
Use @{} to create a hashtable in PowerShell with key-value pairs separated by semicolons.
2
Add allowed drift threshold
Create a variable called $allowedDrift and set it to 0 to define the allowed number of configuration differences.
PowerShell
Hint
Just assign the number 0 to the variable $allowedDrift.
3
Detect configuration drift
Create a hashtable called $actualConfigs with these entries: 'ServerA' = 'v1.2', 'ServerB' = 'v1.4', 'ServerC' = 'v1.2'. Then, create an empty array called $driftedServers. Use a foreach loop with variable $server to iterate over $expectedConfigs.Keys. Inside the loop, compare $actualConfigs[$server] with $expectedConfigs[$server]. If they differ, add $server to $driftedServers.
PowerShell
Hint
Use -ne to check if values are not equal. Use += to add items to an array.
4
Print detected drifted servers
Write a Write-Output statement to print the text 'Servers with configuration drift:'. Then write another Write-Output statement to print the $driftedServers array.
PowerShell
Hint
Use Write-Output to print text and variables in PowerShell.
Practice
(1/5)
1. What is the main purpose of configuration drift detection in PowerShell?
easy
A. To delete temporary files from the system
B. To find unexpected changes in system settings
C. To create new user accounts on a system
D. To install new software updates automatically
Solution
Step 1: Understand configuration drift detection
Configuration drift detection is about identifying changes that were not planned or expected in system settings.
Step 2: Match the purpose with options
Among the options, only finding unexpected changes matches the purpose of configuration drift detection.
Final Answer:
To find unexpected changes in system settings -> Option B