Get-DscResource
Gets Desired State Configuration (DSC) resources present on the computer.
语法
Default (默认值)
Get-DscResource
[[-Name] <String[]>]
[[-Module] <Object>]
[-Syntax]
[<CommonParameters>]
说明
The Get-DscResource
cmdlet retrieves the PowerShell 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, which are created by the user. This cmdlet also shows details about
composite resources, which are other configurations that are packaged as module or created at run
time in the session.
示例
Example 1: Get all resources on the local computer
Get-DscResource
This command gets all the resources on the local computer.
Example 2: Get a resource by specifying the name
Get-DscResource -Name "WindowsFeature"
This command gets the WindowsFeature resource.
Example 3: Get all the resources from a module
Get-DscResource -Module "xHyper-V"
This command gets all the resources from the xHyper-V module.
Example 4: Get a resource by using wildcard characters
Get-DscResource -Name P*,r*
This command gets all resources that match the wildcard pattern specified by the Name parameter.
Example 5: Get a resource syntax
Get-DscResource -Name "WindowsFeature" -Syntax
This command gets the WindowsFeature resource, and shows the syntax for the resource.
Example 6: Get all the properties for a resource
Get-DscResource -Name "User" | Select-Object -ExpandProperty Properties
This command gets the User resource, and then uses the pipeline operator to return all the properties for the User resource.
Example 7: Get all the resources from a specified module with a specified version
Get-DscResource -Module @{ModuleName='xHyper-V';RequiredVersion='3.0.0.0'}
This command gets all the resources from xHyper-V module with version 3.0.0.0.
参数
-Module
Specifies the name or fully qualified name of the module for which to view the DSC resource.
参数属性
类型: | Object |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | 1 |
必需: | False |
来自管道的值: | True |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-Name
Specifies an array of names of the DSC resource to view.
参数属性
类型: | String[] |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | 0 |
必需: | False |
来自管道的值: | True |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | 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 PowerShell script.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.