find-dscresource powershell command

Find-DscResource | Taking on PowerShell one cmdlet at a time | Weekly Blog

Share this post:

This is a part of an on-going blog series written by Adam Gordon. Each week, Adam will walk you through a PowerShell command, showing you when and how to use each one. This week, Adam covers Find-DscResource.

When to use Find-DscResource

The Find-DscResource cmdlet searches registered repositories to find DSC resources contained in modules. By default, Find-DscResource searches all registered repositories.

For each module found by Find-DscResource, a PSGetDscResourceInfo object is returned.

PSGetDscResourceInfo objects can be sent down the pipeline to the Install-Module cmdlet.

 

How to use Find-DscResource

Find all DSC resources:

Find-DscResource

Find-DscResource returns DSC resources from registered repositories. To search a specific repository, use the -Repository parameter.

Find-DscResource powershell command

 

Find a DSC resource by name:

Find-DscResource -Name xDisk, xStorage

Find-DscResource uses the -Name parameter to find the specified array of DSC resources. Use commas to separate an array of resource names.

Find-DscResource powershell command

 

Find a DSC resource and install it:

Find-DscResource -Name xDisk | Install-Module

Find-DscResource uses the –Name parameter to find the resource named xDisk.

The object is sent down the pipeline to the Install-Module cmdlet. Install-Module installs the xDisk module for the resource.

After the installation finishes, you can use Get-InstalledModule to display the results.

Find-DscResource powershell command

Find-DscResource powershell command

Find-DscResource powershell command

 

Find all DSC resources in a module:

Find-DscResource -ModuleName xWebAdministration

Find-DscResource uses the –ModuleName parameter to specify the xWebAdministration and find the DSC resources contained in the module.

The current version of each resource is displayed.

Find-DscResource powershell command

 

Find a resource by using a filter: 

Find-DscResource -Filter Domain

Find-DscResource finds all resources and uses the -Filter parameter to specify the results by Domain.

The -Filter parameter finds the filter value in the object’s description or module name.

You can use the Select-Object cmdlet to view an object’s properties.

Find-DscResource powershell command

Need PowerShell training? Check out ITProTV’s PowerShell online IT training courses.

Leave a Reply

Your email address will not be published. Required fields are marked *