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

Output

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

Output

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

Get-DscResource -Name FilesAndFolders | Select -ExpandProperty Properties

Output

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

Updated on: 01-Sep-2021

450 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements