Folder, File size and timestamp analysis using PowerShell

In just a few lines, one can generate a CSV of all files and their attributes including size and timestamp. I prefer to use TSV (tab delimited) to ensure embedded characters like quotes or commas don’t disrupt the CSV layout.

$q = Get-ChildItem "\serverReserve" -Recurse
#$q | ConvertTo-Csv -NoTypeInformation | out-file "D:DivActAnalyticsACTRDriveFoldersFiles.csv" 
$q2 = $q | select PSPath,PSChildName,	PSIsContainer,BaseName,Length,Name,FullName,Extension,CreationTime,LastAccessTime,LastWriteTime	
foreach ($qItem in $q2)
$qItem.PSPath = $qItem.PSPath.replace("Microsoft.PowerShell.CoreFileSystem::","")
$q2 | ConvertTo-Csv -NoTypeInformation -delimiter "`t" | out-file "D:myFolderReport.csv" 
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *