DSC 文件资源 - overwrite/replace 文件内容
DSC File Resource - overwrite/replace file contents
我正在尝试使用 DSC 文件资源更新一个目录中的一些特定文件。在我的示例中我要更新(即覆盖)的文件存在于目标中,但为空 (0KB)。源中的文件具有完全相同的名称,但有一些内容。使用下面的代码,源文件的内容不会复制到目标文件。知道为什么吗?提前致谢。
Ensure = "Present"
Type = "File"
Force = $true
SourcePath = "somepath\myfile.txt"
DestinationPath = "anotherpath\myfile.txt"
根据回答 :您可能想尝试将 checksum = 'modifiedDate'
和 matchsource = $true
添加到您的属性中。
official doc 自从回答另一个问题后已经移动。
File TheFile {
Ensure = "Present"
Type = "File"
Force = $true
SourcePath = "somepath\myfile.txt"
DestinationPath = "anotherpath\myfile.txt"
checksum = 'modifiedDate'
matchsource = $true
}
我正在尝试使用 DSC 文件资源更新一个目录中的一些特定文件。在我的示例中我要更新(即覆盖)的文件存在于目标中,但为空 (0KB)。源中的文件具有完全相同的名称,但有一些内容。使用下面的代码,源文件的内容不会复制到目标文件。知道为什么吗?提前致谢。
Ensure = "Present"
Type = "File"
Force = $true
SourcePath = "somepath\myfile.txt"
DestinationPath = "anotherpath\myfile.txt"
根据回答 checksum = 'modifiedDate'
和 matchsource = $true
添加到您的属性中。
official doc 自从回答另一个问题后已经移动。
File TheFile {
Ensure = "Present"
Type = "File"
Force = $true
SourcePath = "somepath\myfile.txt"
DestinationPath = "anotherpath\myfile.txt"
checksum = 'modifiedDate'
matchsource = $true
}