How to install DSC resources using PowerShell?

To install the DSC resource using PowerShell, we can use the same command to install modules in PowerShell (Install-Module).

The Find-DscResource command would get all the available DSC resources. To search the specific DSC resource, you can provide the -Name parameter in the Find-DscReource command. For example, we need to search for the FilesAndFolder DSC resource

Find-DSCResource -Name filesandfolders


Name             Version ModuleName Repository
----             ------- ---------- ----------
FilesAndFolders 0.3.212 CommonTasks PSGallery

To install this module, we can pipeline the Install-Module command.

Find-DSCResource -Name filesandfolders | Install-Module -Force -Verbose

Once the module is installed, we can use the Get-DSCResource command to check if the module is installed properly.

Get-DscResource -Name FilesAndFolders


To check the properties of the installed module, we can use the below command.

Get-DscResource -Name FilesAndFolders | Select -ExpandProperty Properties


Name                 PropertyType IsMandatory Values
----                 ------------ ----------- ------
DependsOn             [String[]]     False       {}
PsDscRunAsCredential  [PSCredential] False       {}
Items                 [Hashtable[]]  True        {}