Export (0) Print
Expand All

Get-DscResource

Get-DscResource

Gets the DSC resources present on the computer.

Syntax

Parameter Set: Default
Get-DscResource [[-Name] <String[]> ] [[-Module] <Object> ] [-Syntax] [ <CommonParameters>]




Detailed Description

The Get-DscResource cmdlet retrieves the Desired State Configuration (DSC) resources present on the computer. This cmdlet discovers only the resources installed in the PSModulePath. It shows the details about built-in and custom providers (created by the user), as well as composite resources (other configurations that are packaged as module or created at run time in the session).

Parameters

-Module<Object>

Specifies the name or fully-qualified name of the module for which to view the DSC resource.


Aliases

none

Required?

false

Position?

2

Default Value

none

Accept Pipeline Input?

true(ByValue,ByPropertyName)

Accept Wildcard Characters?

false

-Name<String[]>

Specifies an array of names of the DSC resource to view.


Aliases

none

Required?

false

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Syntax

Indicates that the cmdlet returns the syntax view of the specified DSC resources. The returned syntax shows how to use the resources in a Windows PowerShell® script.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see    about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Microsoft.PowerShell.DesiredStateConfiguration.DscResourceInfo

Examples

Example 1: Get all resources on the local computer

This command gets all the resources on the local computer.


PS C:\> Get-DscResource 

Example 2: Get a resource by specifying the name

This command gets the WindowsFeature resource.


PS C:\> Get-DscResource –Name "WindowsFeature"

Example 3: Get all the resources from a given module

This command gets all the resources from the xHyper-V module.


PS C:\> Get-DscResource –Module "xHyper-V"

Example 4: Get a resource by using wildcard characters

This command gets all resources that match the wildcard pattern specified by the Name parameter.


PS C:\> Get-DscResource –Name P*,r*

Example 5: Get a resource syntax

This command gets the WindowsFeature resource, and shows the syntax for the resource.


PS C:\> Get-DscResource -Name "WindowsFeature" -Syntax

Example 6: Get all the properties for a resource

This command gets the User resource, and then uses the pipeline operator to return all the properties for the User resource.


PS C:\> Get-DscResource -Name "User" | Select-Object -ExpandProperty Properties

Example 7: Get all the resources from a specified module with a specified version

This command gets all the resources from xHyper-V module with version 3.0.0.0


PS C:\> Get-DscResource –Module @{ModuleName=’xHyper-V’;RequiredVersion=’3.0.0.0’}

Related topics

Community Additions

ADD
Show:
© 2016 Microsoft