![]() ![]() ![]() Set-AlternatingRows : The input object cannot be bound to any parameters for the command either because the command doe Write-Verbose "$(Get-Date): Script completed!" Write-Verbose "$(Get-Date): $NumDirs folders processed" #Display the report in your default browser $HTML = $Report | Select 'Folder Name',Owner,'Created On','Last Updated',Size | Sort $SortBy -Descending:$Descending | ConvertTo-Html -PreContent $Pre -PostContent $Post -Head $Header | Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd | Out-File $ReportPath\FolderSizes.html $Post = "Total Folders Processed: $NumDirsTotal Space Used: $TotalSizeRun on $(Get-Date -f 'MM/dd/yyyy hh:mm:ss tt')" $Pre = "Folder Sizes ReportFolders processed: ""$($Title -join ", ")""" Owner = (Get-Acl $FileObject.FullName).Ownerįolder Sizes for = CalculateSize $TotalSize 'Last Updated' = $FileObject.LastWriteTime $Object = New-Object PSObject -Property Name' = $FileObject.FullName $RawSize = (Get-ChildItem $FileObject.FullName -Recurse | Measure-Object Length -Sum).Sum (Run from Powershell and navigate to where you saved the script to) Updated to use the ComObject Scripting.FileSystemObject, inspired by:ĭownload file and save as Get-FolderSizes.ps1. Originally inspired by this question in the Powershell forum: Recurse will do all sub-folders.Įver wanted to get a list of folders and their sizes? This script will produce a nice HTML report with folder path, Owner, folder creation time, last updated time and size of folder. V1.3: Added Recurse parameter and changed default behavior of script to do only 1 level of folders. V1.4: Added Sort and Descending parameters to control the sort of your report. Tightened up the final report so it looks a little better.ġ.41: found a bug in the Total Size reporting. ![]() I figure SOME result is better than none. While the COM object is much faster, it will return 0 if it has any problem in the folder structure (such as a typical access denied when running against C:\Windows). Also switched away from using the COM Object. 1.5: Added ability to process multiple paths, both from array input as well as from the pipeline. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |