Taking on PowerShell one cmdlet at a time

Share this post:This blog post is part of an ongoing series by Adam Gordon. Adam will show you how to use each PowerShell command each week. This week Adam will be covering Find-DscResource.

When to use Find-DscResource
The Find-DscResource cmdlet searches all registered repositories in order to find DSC resources within modules. Find-DscResource searches all registered repositories by default.
A PSGetDscResourceInfo object returns information for each module that Find-DscResource finds.
PSGetDscResourceInfo objects may be sent down the pipeline towards the Install-Module cmdlet.

How to use Find-DscResource
All DSC resources available:
Find-DscResource returns DSC resources for registered repositories. Use the -Repository parameter to search for a specific repository.

Name a DSC resource:
Find-DscResource – Name xDisk, xStorage
To find the specified array DSC resources, Find-DscResource uses a parameter called -Name. Separate multiple resource names using commas

Install a DSC resource.
Find-DscResource -Name xDisk | Install-Module
To find the resource named xDisk, Find-DscResource uses a parameter called -Name.
The object is sent through the pipeline to the Install Module cmdlet. Install-Module installs xDisk for the resource.
You can display the results by using Get-InstalledModule after the installation is complete.

Find all DSC resources within a module:
Find-DscResource uses a parameter called -ModuleName to specify the xWebAdministration. It then searches for DSC resources within the module.
Each resource’s current version is displayed.

Use a filter to find the right resource:
Filter Domain with Find-DscResource
Find-DscResource searches for all resources and uses -Filter to specify the Domain results.
The -Filter parameter searches for the filter value within the object’s description, or module name.
To view the properties of an object, you can use the Select-Object cmdlet

Find-Command: Last week’s command
Do you need PowerShell training? ITProTV offers PowerShell online IT training courses.

Previous post Taking on PowerShell one cmdlet at a time
Next post Taking on PowerShell one cmdlet at a time