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 --versionand record the version number - Run each DSC command and name the available options (except for
--versionand--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 = $truewhen usingset - Implements
getoperation to retrieve current registry key state - Implements
testoperation to verify if key exists and matches desired state - Implements
deleteoperation when_exist = $falseis specified - Uses the
Microsoft.Windows/RegistryDSC 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-Jsonto parse DSC output for better handling - Remember:
deleterequires setting_existto 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?