Practicing and exploring
Time to test your knowledge and understanding by performing exercises and answering some questions. Get your hands dirty with the following exercises.
1
Easy
Verify your Microsoft DSC installation
Confirm that Microsoft DSC is properly installed and accessible from your command line, and document your system configuration.
Your Task
Complete the following verification steps:
- Run
dsc --version
and record the version number - Run each DSC command and name the available options (except for
--version
and--help
) - List out the available DSC functions and count how many are available
- Document your OS, architecture, and edition using a DSC resource
Hints
- If the command is not found, check your PATH environment variable
- On Windows, you may need to restart your terminal after adding to PATH
2
Medium
Create registry management script
Build a PowerShell script that manages registry keys using the Microsoft.Windows/Registry
resource with full CRUD operations and driven behavior using parameters.
Your Task
Create a PowerShell script that:
- Accepts parameters for operation type (
get
,set
,test
,delete
) - Creates a registry key with
_exist = $true
when usingset
- Implements
get
operation to retrieve current registry key state - Implements
test
operation to verify if key exists and matches desired state - Implements
delete
operation when_exist = $false
is specified - Uses the
Microsoft.Windows/Registry
DSC resource - Includes error handling and validation
- Provides clear output showing the operation result in PowerShell objects
Hints
- Use a
[ValidateSet]
attribute for the operation parameter - Build the JSON input dynamically based on the operation
- Use
ConvertFrom-Json
to parse DSC output for better handling - Remember:
delete
requires setting_exist
to false in the input - Test your script with HKCU hive to avoid needing admin privileges
3
Easy
Knowledge check
Test your understanding of core Microsoft DSC concepts, architecture, and how it differs from traditional configuration management tools.
Questions
- What does DSC stand for, and what problem does it solve in configuration management?
- How does DSC differ from imperative configuration tools?
- What does it mean when we say DSC is idempotent?
- What's the role of a DSC Resource?
- How do DSC configuration documents describe the desired state of a system?
- What are the main operations supported by DSC resources?
- How is DSC different from PowerShell DSC in terms of dependencies and architecture?
- What formats can DSC configuration documents be written in?
- Why doesn't the new DSC include a Local Configuration Manager?