DSC File Resource - copy file

僤鯓⒐⒋嵵緔 提交于 2021-01-27 14:12:37

问题


I'm using a PowerShell DSC Pull Server. It's possible to use the File resource to copy a file every time is modified? I've tried the below:

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

but no luck: if I modify the file from SourcePath I'd expect that the destination file should be updated too.


回答1:


Add MatchSource, See documentation here.

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


来源:https://stackoverflow.com/questions/33233031/dsc-file-resource-copy-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!