Best practices

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 alternatively use IntelliJ IDEA. 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 #

CommandAction
Update DSC configuration on local computerUpdate-DscConfiguration -verbose -wait
Run DSC configuration on local computerStart-DscConfiguration -verbose -wait -useexisting
Get DSC local configuration managerGet-DscLocalConfigurationManager
Get all DSC resources from a DSC ModuleGet-DscResource-Name xoap* -Module xoap*

Debugging (DSC) cmdlets #

CommandAction
Stops debugging of DSC resourcesDisable-DscDebug
Starts debugging of all DSC resourcesEnable-DscDebug
Gets the current configuration of the nodesGet-DscConfiguration
Retrieves data about completed configuration runsGet-DscConfigurationStatus
Gets LCM settings and states for the nodeGet-DscLocalConfigurationManager
Gets the DSC resources present on the computerGet-DscResource
Runs a method of a specified DSC resourceInvoke-DscResource
Creates checksum files for DSC documents and DSC resourcesNew-DscCheckSum
Publishes a DSC configuration to a set of computersPublish-DscConfiguration
Removes a configuration document from the DSC configuration storeRemove-DscConfigurationDocument
Reapplies the previous configuration for the nodeRestore-DscConfiguration
Applies LCM settings to nodesSet-DscLocalConfigurationManager
Applies configuration to nodesStart-DscConfiguration
Stops a running configurationStop-DscConfiguration
Tests whether the actual configuration on the nodes matches the desired configurationTest-DscConfiguration
Checks the pull server for an updated configuration and applies itUpdate-DscConfiguration

Powered by BetterDocs

Scroll to Top