2017-07-05 82 views

回答

0

最簡單的一個(將遞歸地尋找文件夾(S)所有XML文件):

$folder1 = "" 
$folder2 = "" 

$fol1 = Get-ChildItem -Recurse $folder1 -Filter *.xml| select name, directory, CreationTime 
$fol2 = Get-ChildItem -Recurse $folder2 -Filter *.xml| select name, directory, CreationTime 

Compare-Object $fol1 $fol2 -Property name -PassThru | select name, CreationTime, @{ 
    N = "Folder"; e= { 
     if ($_.sideindicator -eq "=>") { "Not Found in $folder2" } 
     elseif ($_.sideindicator -eq "<=") { "Not Found in $folder1" } 
    } 
} 

輸出:

Name     CreationTime   Folder 
----     ------------   ------ 
New Text Document.txt 7/5/2017 1:24:35 PM  Not Found in G:\xxx 
1.exe     6/14/2017 3:17:29 PM Not Found in G:\111 
1.dll     6/14/2017 3:17:37 PM Not Found in G:\1 
相關問題