When trying to list the full path of all files in a folder and its subfolders, the Out-File cmdlet truncats the path for files with the long path.
It turns out that Out-File outputs the data with the same width of the PowerShell console (see Using the Out-File Cmdlet).
To work around the issue, include the –width parameter and specify a different line width(e.g. –width 4096). This outputs every line with 4096 characters long (pedding with spaces).
To output line width to match the longest output, add Ft –autosize before Out-File. For example:
Get-ChildItem -File -Recurse -Path Z:\ | where {$_.LastWriteTime -gt "MM/DD/YYYY"} | select FullName | Ft -autosize | Out-File c:\temp\modified.file.txt -Width 4096
No comments:
Post a Comment