Remove recursion for files to speed up execution

This commit is contained in:
Ryan McCallum 2021-06-15 18:34:03 -04:00
Родитель 7d38be91af
Коммит e4018eb2d9
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -192,7 +192,13 @@ try {
# Confirm file exists
if (Test-Path $logLocation) {
$itemToCopy = Get-ChildItem -Recurse $logLocation -Force -ErrorAction SilentlyContinue -ErrorVariable getLogItemErrors -WarningAction SilentlyContinue -WarningVariable getLogItemWarnings
if (Test-Path $logLocation -PathType Container) {
$itemToCopy = Get-ChildItem -Recurse $logLocation -Force -ErrorAction SilentlyContinue -ErrorVariable getLogItemErrors -WarningAction SilentlyContinue -WarningVariable getLogItemWarnings
}
elseif (Test-Path $logLocation -PathType Leaf) {
$itemToCopy = Get-ChildItem $logLocation -Force -ErrorAction SilentlyContinue -ErrorVariable getLogItemErrors -WarningAction SilentlyContinue -WarningVariable getLogItemWarnings
}
foreach ($collectedLog in $itemToCopy) {
$collectedLogArray += $collectedLog.FullName
}