我正在编写一个Powershell脚本,该脚本在将新文档添加到文件夹并另存为文本文件时创建一个散列函数。我有两个文本文件,里面有太多的记录。我想要比较文本文档并找到相同的值,但当我尝试保存新的txt文件时,它是空的。
C:\Temp\Project\Backup\Archives\Batch\SB6_1-2-741245d_batch.pdf
4865CA20AC06CFE22078BC8BE9E358D7 C:\Temp\Project\Backup\Archives\Batch\SB6_1-2-74794567standard_batch.bar
这些是txt文件中的示例值。我在另一个txt文件中有相同的记录。我可以比较这些值,但是当我保存新的txt文件时,它是空的。下面是我的比较脚本:
Compare-Object -ReferenceObject $(Get-Content
C:\Users\william\Documents\try1\a1.txt) -IncludeEqual $(Get-Content
C:\Users\william\Documents\try1\a2.txt)
Out-File C:\Users\william\Documents\try1\a3.txt -Encoding utf8
发布于 2019-06-11 11:40:38
这就是我怎么做的,它起作用了。
$path = "C:\Users\william\Documents\try1"
Compare-Object -ReferenceObject $(Get-Content $path\a1.txt) -IncludeEqual $(Get-Content $path\a2.txt) | Out-File $path\a3.txt -Encoding utf8
https://stackoverflow.com/questions/56532036
复制相似问题