powershell 演示Dsc101.ps1

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 演示Dsc101.ps1相关的知识,希望对你有一定的参考价值。


<#
[Video] A Practical Overview of Desired State Configuration
http://channel9.msdn.com/events/TechEd/NorthAmerica/2014/DCIM-B417

[eBook] PowerShell.org DSC Hub
http://powershell.org/wp/dsc-hub/

[TechNet] Windows PowerShell Desired State Configuration Overview
http://technet.microsoft.com/en-us/library/dn249912.aspx

[Gallery] DSC Resources
https://www.powershellgallery.com/

[GitHub] DSC Resource source code
https://github.com/PowerShell/DscResources
#>

###
### Define the configuration
###
configuration Foo
{
    # One can evaluate expressions to get the node list
    # E.g: $AllNodes.Where("Role -eq Web").NodeName
    node (hostname)
    {
        # Call Resource Provider
        # E.g: WindowsFeature, File
        WindowsFeature XPSViewer
        {
           Ensure = "Present"
           Name   = "XPS-Viewer"
        }
    }
}

###
### Generate the MOF file from the Configuration
###
foo -OutputPath C:\DSC\Foo

###
### View the generated MOF
###
psedit "C:\DSC\Foo\$(hostname).mof"

###
### Process the configuration in the LCM (make it so!)
###
Start-DscConfiguration -Wait -Verbose -Path C:\DSC\Foo -Force

###
### Check the result, did it install?
###
Get-WindowsFeature -name XPS-Viewer | Remove-WindowsFeature

###
### Check on the status of the configuration
###
Get-DscConfigurationStatus

###
### Get the actual configuration
###
Get-DscConfiguration

###
### Get the local configuration manager (LCM) configuration
###
Get-DscLocalConfigurationManager

###
### Get the DSC resources on the computer
###
Get-DscResource

###
### Find the DSC resources in the gallery
###
Find-DscResource

###
### Next Demo...
###
### https://gist.github.com/mgreenegit/c366f14ed82c6139aa3c

以上是关于powershell 演示Dsc101.ps1的主要内容,如果未能解决你的问题,请参考以下文章

PowerShell DSC学习资料

powershell 示例DSC

powershell DSC复制并使用模块运行本地

powershell DSC推动CIMSession

MCSA2016_004 - PowerShell DSC -

11.PowerShell DSC之安装PowerShell Module