0
0
PowerShellscripting~10 mins

Desired State Configuration (DSC) basics in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a DSC configuration named 'MyConfig'.

PowerShell
Configuration MyConfig {
    Node localhost {
        File ExampleFile {
            DestinationPath = 'C:\Temp\example.txt'
            Contents = 'Hello DSC!'
            Ensure = '[1]'
        }
    }
}
Drag options to blanks, or click blank then click option'
APresent
BInstalled
CRunning
DEnabled
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Installed' which is not valid for File resource.
Using 'Running' or 'Enabled' which apply to services, not files.
2fill in blank
medium

Complete the code to apply the DSC configuration stored in 'MyConfig'.

PowerShell
Start-DscConfiguration -Path '[1]' -Wait -Verbose
Drag options to blanks, or click blank then click option'
AC:\Configs\MyConfig
BC:\Temp\MyConfig
CC:\DSC\MyConfig
DC:\Scripts\MyConfig
Attempts:
3 left
💡 Hint
Common Mistakes
Using a path that does not contain the MOF files.
Confusing script folder with configuration folder.
3fill in blank
hard

Fix the error in the DSC configuration to ensure the service 'Spooler' is running.

PowerShell
Configuration ServiceConfig {
    Node localhost {
        Service PrintSpooler {
            Name = 'Spooler'
            State = '[1]'
        }
    }
}
Drag options to blanks, or click blank then click option'
AStopped
BEnabled
CPresent
DRunning
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Present' which is invalid for service state.
Using 'Enabled' which controls startup type, not running state.
4fill in blank
hard

Fill both blanks to create a DSC configuration that ensures the 'C:\Logs' folder exists and the 'W32Time' service is running.

PowerShell
Configuration MultiResourceConfig {
    Node localhost {
        File LogsFolder {
            DestinationPath = 'C:\Logs'
            Ensure = '[1]'
            Type = 'Directory'
        }
        Service TimeService {
            Name = 'W32Time'
            State = '[2]'
        }
    }
}
Drag options to blanks, or click blank then click option'
APresent
BRunning
CStopped
DAbsent
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Absent' for folder when it should exist.
Using 'Stopped' for service when it should be running.
5fill in blank
hard

Fill all three blanks to create a DSC configuration that ensures a file exists, a service is running, and the configuration is applied.

PowerShell
Configuration FullConfig {
    Node localhost {
        File ConfigFile {
            DestinationPath = 'C:\Config\settings.ini'
            Contents = 'mode=auto'
            Ensure = '[1]'
        }
        Service ConfigService {
            Name = 'ConfigSvc'
            State = '[2]'
        }
    }
}

FullConfig
Start-DscConfiguration -Path '[3]' -Wait -Verbose
Drag options to blanks, or click blank then click option'
APresent
BRunning
C.\FullConfig
DStopped
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Stopped' for service state.
Using wrong path for Start-DscConfiguration.