Tools #
In order to write PowerShell DSC Configurations, you need some tools to get you started.
WMF 5.1 #
If it’s not already installed, you should install the Windows Management Framework 5.1.
If you’re running Windows 10 or Windows Server 2016 and above, it should already be installed.
PowerShell Get #
Run the following commands as administrator on your Windows machine:
Install-Module -Name PowerShellGet -Force
Learn more about PowerShell Get.
Code editors #
You’ll need a suitable source code editor, so we recommend one of the following.
Visual Studio Code #
Visual Studio Code is our preferred code editor for all PowerShell-related topics. It can be downloaded here. You can install it for a user or as a system installer. Choose the installer that fits your needs.
IntelliJ IDEA #
If you’re not a fan of Visual Studio Code, you can use IntelliJ IDEA as an alternative. It can be downloaded here.
PowerShell ISE #
PowerShell ISE is another code editor you can use to edit your DSC configurations, but we strongly recommend one of the two above.
Additional DSC Resources #
Additional DSC Resources can be downloaded from PowerShell Gallery. The modules you need to download depend on the configuration you want to create. Browse through the PowerShell Gallery to find the resources you need.
If the resources are not there yet, feel free to write your own.
They are installed via PowerShell:
Install-Module -Name xWindowsUpdate
Naming conventions #
Follow the guidelines below to ensure the correct processing:
- Standard names may only contain letters (a-z, A-Z), numbers (0-9), and underscore (_)
- The name may not be null (0), empty ( ) or written with hyphen (-), and should start with a letter (a-z, A-Z)
Valid naming examples #
“XOAP_Any_Apps_And_Monitoring”
“xoap_any_apps_and_monitoring_0_1_9”
“XOAP_Hp_Dl380_Baseline_Configuration”
“xoap_hp_dl380_baseline_configuration”
Invalid naming example #
“XOAP-W10-20H2-Citrix-Optimizer”
“01 XOAP W10 20H2 Citrix Optimizer”
Commands and actions #
Desired State Configuration (DSC) cmdlets for everyday usage #
Command | Action |
---|---|
Update DSC configuration on local computer | Update-DscConfiguration -verbose -wait |
Run DSC configuration on local computer | Start-DscConfiguration -verbose -wait -useexisting |
Get DSC local configuration manager | Get-DscLocalConfigurationManager |
Get all DSC resources from a DSC Module | Get-DscResource-Name xoap* -Module xoap* |
Debugging (DSC) cmdlets #
Command | Action |
---|---|
Stops debugging of DSC resources | Disable-DscDebug |
Starts debugging of all DSC resources | Enable-DscDebug |
Gets the current configuration of the nodes | Get-DscConfiguration |
Retrieves data about completed configuration runs | Get-DscConfigurationStatus |
Gets LCM settings and states for the node | Get-DscLocalConfigurationManager |
Gets the DSC resources present on the computer | Get-DscResource |
Runs a method of a specified DSC resource | Invoke-DscResource |
Creates checksum files for DSC documents and DSC resources | New-DscCheckSum |
Publishes a DSC configuration to a set of computers | Publish-DscConfiguration |
Removes a configuration document from the DSC configuration store | Remove-DscConfigurationDocument |
Reapplies the previous configuration for the node | Restore-DscConfiguration |
Applies LCM settings to nodes | Set-DscLocalConfigurationManager |
Applies configuration to nodes | Start-DscConfiguration |
Stops a running configuration | Stop-DscConfiguration |
Tests whether the actual configuration on the nodes matches the desired configuration | Test-DscConfiguration |
Checks the pull server for an updated configuration and applies it | Update-DscConfiguration |