powershell - DSC 文件资源 - 复制文件

标签 powershell dsc

我正在使用 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
    }

关于powershell - DSC 文件资源 - 复制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33233031/

相关文章:

powershell - 自定义资源 : Is it okay to reapply settings every time?

iis-7 - 如何在 PowerShell 中迭代应用程序 IIS7 的身份验证

javascript - 重复输出到控制台 - 我必须在哪里插入我的回调?

powershell - 有没有更快的方法来制作多个子目录?

powershell - 如何在 Powershell 中同时对多个服务器运行命令

Powershell DSC xChrome 示例在 AzureVM 上失败

powershell - Azure Powershell 模板 : return Boolean if all resource provisioned successfully?

powershell - 在 DSC 中使用文件提供程序 - 确保目标仅包含来自源的文件

windows - 未找到内置 DSC 资源

powershell - 复合资源中的导入 DSCResource