8.PowerShell DSC之Push

前言

LCM的默认mode就是push,所以对于push模式,我们直接就三步走
image

以下是示例:

1.编写配置 Authoring

Configuration WebsiteTest {

    # Import the module that contains the resources we're using.
    Import-DscResource -ModuleName PsDesiredStateConfiguration

    # The Node statement specifies which targets this configuration will be applied to.
    Node 'TargetComputerName' {

        # The first resource block ensures that the Web-Server (IIS) feature is enabled.
        WindowsFeature WebServer {
            Ensure = "Present"
            Name   = "Web-Server"
        }

        # The second resource block ensures that the website content copied to the website root folder.
        File WebsiteContent {
            Ensure = 'Present'
            SourcePath = 'c:\test\index.htm'
            DestinationPath = 'c:\inetpub\wwwroot'
        }
    }
}

2.编译配置 Staging

. .\WebsiteTest.ps1
WebsiteTest

3.应用配置 Execution

Start-DscConfiguration .\WebsiteTest

参考

https://www.red-gate.com/simple-talk/sysadmin/powershell/powershell-desired-state-configuration-lcm-and-push-management-model/

https://docs.microsoft.com/en-us/powershell/dsc/quickstarts/website-quickstart

转载于:https://www.cnblogs.com/talentzemin/p/11587513.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值