try using a literal path

This commit is contained in:
2024-08-08 13:13:54 -04:00
parent 644cd0cd14
commit 11317ef618
+3 -2
View File
@@ -804,9 +804,10 @@ Function Get-FileSizes {
}
# Get the file paths and sizes as specified
$FileSizes = Get-ChildItem $Path -Recurse:$Recurse -Force:$IncludeHidden -ErrorAction SilentlyContinue | `
$FileSizes = Get-ChildItem -LiteralPath "\\?\${Path}" -Recurse:$Recurse -Force:$IncludeHidden -ErrorAction SilentlyContinue | `
Where-Object { ! $_.PSIsContainer -and ($_.FullName.Length -lt 260)} | `
Sort-Object -Descending:$SortOrder -Property Length | `
Select-Object -First $Quantity @{Name="File Path";Expression={$_.DirectoryName + '\' + $_.Name}}, @{Name=$UnitLabel;Expression={[Math]::Round($_.Length / $Divisor, $Precision)}}
Select-Object -First $Quantity @{Name="File Path";Expression={[IO.Path]::Combine($_.DirectoryName, $_.Name)}}, @{Name=$UnitLabel;Expression={[Math]::Round($_.Length / $Divisor, $Precision)}}
# Set output prefix
$prefix = "The ${Quantity} " + $PSCmdlet.ParameterSetName + " files found at ""${Path}"""