Note: This article applies to Windows Management Framework (WMF) 5.0 Preview release only.
Windows PowerShell team made a formal announcement of PowerShell Gallery availability (limited preview) last month. The PowerShell Gallery is the place where people can publish their PowerShell modules and DSC resources. People who are interested in using those modules or DSC resources can explore and install them from the PowerShell Gallery directly. This is made possible using a module called PowerShellGet in Windows Management Framework (WMF) 5.0 Preview release.
I published my DSC resource modules to the PowerShell Gallery. So, in this article, I will show you how to find the DSC resources in these modules and install them.
There are two different ways you can explore PowerShell Gallery for DSC resources.
The Find-Module cmdlet is a part of the PowerShellGet module in WMF 5.0 Preview release. Using this cmdlet, we can find PowerShell modules and DSC resources published in the PowerShell Gallery.
Find-Module -Includes DscResource -Verbose
The possible valid arguments for the -Includes parameter include DscResource, Cmdlet, and Function. By specifying DscResource, we specify the intent that we are interested in modules that include DSC resources.
At the time of this writing, note that there are only five resource modules listed here whereas there are more than 50 DSC resource modules in the PowerShell Gallery. This is a known issue.
Find-Module -Tag DSC
This will list all modules that carry a “DSC” tag that was added while publishing the module. This is not a fool-proof method. If the author did not add this tag during publish phase, it won’t appear in this list even when the module contains DSC resources.
The PSDesiredStateConfiguration module in Windows PowerShell 5.0 Preview has a new cmdlet called Find-DscResource. Don’t confuse this with Get-DscResource. The Get-DscResource gets all DSC resources available on the local system whereas Find-DscResource gets you DSC resources from the PowerShell Gallery or any other repository specified using the -Repository parameter.
You can use -Tag property to search for specific tags used while publishing the resource module.
Installing DSC resource modules
The Install-Module cmdlet can be used to install DSC resource modules from the gallery.
When you use the Install-Module cmdlet with just the -Name parameter, the default install location for the module will be ‘C:\Program Files\WindowsPowerShell\Modules‘. So, this requires administrative privileges. However, if you want to install the module in the current user context without administrator privileges, you can do so using the -Scope parameter by setting it to CurrentUser.
Once you understand how to use these cmdlets, you can point them towards a local repository too.