0
0
PowerShellscripting~20 mins

Desired State Configuration (DSC) basics in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
DSC Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this DSC configuration block?
Given the following DSC configuration, what will be the output when you run Start-DscConfiguration -Path .\MyConfig -Wait -Verbose?
PowerShell
Configuration MyConfig {
    Node localhost {
        File ExampleFile {
            DestinationPath = "C:\\Temp\\example.txt"
            Contents = "Hello DSC"
            Ensure = "Present"
        }
    }
}

MyConfig
Start-DscConfiguration -Path .\MyConfig -Wait -Verbose
AThe file is created but empty because Contents is ignored.
BAn error occurs because the DestinationPath is invalid.
CThe file C:\Temp\example.txt is created with content 'Hello DSC'.
DNothing happens because the configuration is not applied.
Attempts:
2 left
💡 Hint
Think about what the File resource does in DSC and what the Ensure property means.
📝 Syntax
intermediate
2:00remaining
Identify the syntax error in this DSC configuration snippet
Which option correctly fixes the syntax error in this DSC configuration snippet?
PowerShell
Configuration SampleConfig {
    Node localhost {
        File SampleFile {
            DestinationPath = "C:\\Temp\\sample.txt"
            Contents "Sample content"
            Ensure = "Present"
        }
    }
}
AAdd an equals sign after Contents: Contents = "Sample content"
BRemove the quotes around Sample content: Contents = Sample content
CAdd a comma after Contents: Contents = "Sample content",
DChange DestinationPath to Destination = "C:\\Temp\\sample.txt"
Attempts:
2 left
💡 Hint
Look carefully at the property assignments inside the resource block.
🔧 Debug
advanced
2:00remaining
Why does this DSC configuration fail to apply?
This DSC configuration is supposed to create a directory, but it fails. What is the reason?
PowerShell
Configuration CreateFolder {
    Node localhost {
        File NewFolder {
            DestinationPath = "C:\\NewFolder"
            Type = "Directory"
            Ensure = "Present"
        }
    }
}

CreateFolder
Start-DscConfiguration -Path .\CreateFolder -Wait -Verbose
AThe Node name 'localhost' is invalid and should be replaced with the actual computer name.
BThe DestinationPath is missing a trailing backslash.
CThe Ensure property must be set to 'Created' instead of 'Present'.
DThe 'Type' property is invalid; it should be 'Type = 'Directory'' is correct, but the File resource does not support 'Type'.
Attempts:
2 left
💡 Hint
Check the documentation for the File resource properties.
🚀 Application
advanced
2:00remaining
How to ensure a Windows feature is installed using DSC?
You want to use DSC to make sure the 'Web-Server' Windows feature is installed on a server. Which configuration snippet will achieve this?
A
Configuration WebServer {
    Node localhost {
        WindowsFeature IIS {
            Name = "Web-Server"
            Ensure = "Present"
        }
    }
}
B
Configuration WebServer {
    Node localhost {
        WindowsFeature IIS {
            FeatureName = "Web-Server"
            State = "Installed"
        }
    }
}
C
Configuration WebServer {
    Node localhost {
        WindowsFeature IIS {
            Name = "Web-Server"
            State = "Present"
        }
    }
}
D
Configuration WebServer {
    Node localhost {
        WindowsFeature IIS {
            FeatureName = "Web-Server"
            Ensure = "Installed"
        }
    }
}
Attempts:
2 left
💡 Hint
Check the correct property names and values for the WindowsFeature resource.
🧠 Conceptual
expert
2:00remaining
What happens if you run Start-DscConfiguration twice with the same configuration?
You have applied a DSC configuration named 'MyConfig' on a node. You run Start-DscConfiguration -Path .\MyConfig -Wait -Verbose again immediately. What will happen?
ADSC will uninstall all resources and then apply the configuration again.
BDSC will reapply the configuration and recreate all resources regardless of current state.
CDSC will throw an error because the configuration is already applied.
DDSC will detect the node is already in the desired state and make no changes.
Attempts:
2 left
💡 Hint
Think about the purpose of DSC's idempotency.