在使用PowerShell DSC的时候,我们经常需要使用 PSDesiredStateConfiguration的一些常用的命令去配置或者获取一些DSC的配置信息已经设置DSC的LCM的状态等信息;那么PowerShell DSC 5.x 提供了哪些功能和cmdlet?
我们通常可以用下面的命令列出所有的PSDesiredStateConfiguration的常规命令.
PS C:\DSC> Get-Command -Module PSDesiredStateConfiguration
CommandType Name Version Source
----------- ---- ------- ------
Function Configuration 1.1 PSDesiredStateConfiguration
Function Disable-DscDebug 1.1 PSDesiredStateConfiguration
Function Enable-DscDebug 1.1 PSDesiredStateConfiguration
Function Get-DscConfiguration 1.1 PSDesiredStateConfiguration
Function Get-DscConfigurationStatus 1.1 PSDesiredStateConfiguration
Function Get-DscLocalConfigurationManager 1.1 PSDesiredStateConfiguration
Function Get-DscResource 1.1 PSDesiredStateConfiguration
Function New-DscChecksum 1.1 PSDesiredStateConfiguration
Function Remove-DscConfigurationDocument 1.1 PSDesiredStateConfiguration
Function Restore-DscConfiguration 1.1 PSDesiredStateConfiguration
Function Stop-DscConfiguration 1.1 PSDesiredStateConfiguration
Cmdlet Invoke-DscResource 1.1 PSDesiredStateConfiguration
Cmdlet Publish-DscConfiguration 1.1 PSDesiredStateConfiguration
Cmdlet Set-DscLocalConfigurationManager 1.1 PSDesiredStateConfiguration
Cmdlet Start-DscConfiguration 1.1 PSDesiredStateConfiguration
Cmdlet Test-DscConfiguration 1.1 PSDesiredStateConfiguration
Cmdlet Update-DscConfiguration 1.1 PSDesiredStateConfiguration
比如,我们可以用Get-DscResource 命令列出所有的DSC的resource的名字;也能具体列出某一个DSC resource的名字,以及
其具体的属性。
PS C:\DSC> $gc = Get-DscResource -Name MSFT_xChrome ; $gc.Properties
Name PropertyType IsMandatory Values
---- ------------ ----------- ------
DependsOn [String[]] False {}
PsDscRunAsCredential [PSCredential] False {}
Language [String] False {}
LocalPath [String] False {}