DSC 文件资源 - 复制文件

DSC File Resource - copy file

我正在使用 PowerShell DSC 拉取服务器。 每次修改都可以使用文件资源复制文件吗? 我试过以下方法:

        File Test{
        DestinationPath = "c:\yyy\test.txt"
        SourcePath = "\share\test.txt"
        Ensure = "Present"
        Type = "File"
        Credential = $Credential
        Checksum = "modifiedDate"
        Force = $true}

但运气不好:如果我从 SourcePath 修改文件,我希望目标文件也应该更新。

添加 MatchSource,参见文档 here

    File Test{
        DestinationPath = "c:\yyy\test.txt"
        SourcePath = "\share\test.txt"
        Ensure = "Present"
        Type = "File"
        Credential = $Credential
        Checksum = "modifiedDate"
        Force = $true
        MatchSource = $true
    }