Created
August 4, 2023 14:48
-
-
Save winkler-winsen/b13677e507f07e8ed92bb6f35a64eeec to your computer and use it in GitHub Desktop.
PowerShell: compare Get-ChildItem vs. cmd.exe dir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Path='C:\' | |
$SearchFiles=@( | |
'.exe', | |
'.dll' | |
) | |
Write-Host "Suche Dateien..." | |
Write-Host "--------- GCI -------------" | |
Measure-Command { | |
Get-ChildItem -Path $Path -Recurse -Force -File -ErrorAction SilentlyContinue -OutVariable FindingsGCI -Include $SearchFiles | |
$Findings=$FindingsGCI | |
} -OutVariable TimeGCI | |
#$Findings.FullName | |
#Ticks : 2716068253 | |
#TotalDays : 0,0031435975150463 | |
#TotalHours : 0,0754463403611111 | |
#TotalMinutes : 4,52678042166667 | |
#TotalSeconds : 271,6068253 | |
#TotalMilliseconds : 271606,8253 | |
Write-Host "--------- dir ----------" | |
Measure-Command { | |
$FindingsDirAll = & cmd.exe /c "dir $($p) /a-d /s /b" | |
$SearchFilesRegex = [string]::Join('|', $SearchFiles) | |
$Findings=Get-ChildItem ($FindingsDirAll -match $SearchFilesRegex) -ErrorAction SilentlyContinue | |
} -OutVariable TimeDir | |
#$Findings.FullName | |
#Ticks : 503975332 | |
#TotalDays : 0,000583304782407407 | |
#TotalHours : 0,0139993147777778 | |
#TotalMinutes : 0,839958886666667 | |
#TotalSeconds : 50,3975332 | |
#TotalMilliseconds : 50397,5332 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment