PowerShell: Function doesn't have proper return value
问题 I wrote a powershell script to compare the content of two folders: $Dir1 ="d:\TEMP\Dir1" $Dir2 ="d:\TEMP\Dir2" function Test-Diff($Dir1, $Dir2) { $fileList1 = Get-ChildItem $Dir1 -Recurse | Where-Object {!$_.PsIsContainer} | Get-Item | Sort-Object -Property Name $fileList2 = Get-ChildItem $Dir2 -Recurse | Where-Object {!$_.PsIsContainer} | Get-Item | Sort-Object -Property Name if($fileList1.Count -ne $fileList2.Count) { Write-Host "Following files are different:" Compare-Object