这Compare-Object
不起作用,但有没有办法做同样的事情?
For ($F=0; $F -le $NumberOfSameFolders; $F++)
{
$Results$F = Compare-Object "$FilesInFolderX$F" "$FilesInFolderY$F"
-Property Name, LastWriteTime -IncludeEqual -PassThru |
Select-Object FullName
}
这是一个适用于第20对文件夹的实验。
$Results20 = Compare-Object $FilesInFolderX20 $FilesInFolderY20
-Property Name, LastWriteTime -PassThru | Select-Object FullName
答案 0 :(得分:1)
以下是使用Get-Variable
CmdLet
$a1 = 12,13
$a2 = 13,14
$b = 1
Compare-Object (Get-Variable "a$b").Value (Get-Variable -Name "a$($b+1)").Value
在您的情况下,您可以使用:
Compare-Object (Get-Variable "$FilesInFolderX$F").value (Get-Variable "$FilesInFolderY$F").value