$recursiveHTML += "" + $folderItem.Name + " (" + $folderDetails.FolderSizeInUnits + " " + $folderDetails.Units + ")" $recursiveHTML += "" + $folderItem.Name + " (" + $folderDetails.FolderSizeInUnits + " " + $folderDetails.Units + ")" + "" #If has subfolders, create hmtl drilldown. $subFolderItems = Get-ChildItem $FolderPath -recurse -force | Where-Object | Sort-Object #Get the total size of the folder by recursively summing its children $htmlLines = that creates a folder detail record $destinationHTMLFile = "C:\final.html" #The final html file that will be produced, #does not need to exist $sourceHTMLFile = "C:\finalTemplate.html" #The html source template file $startFolder = "C:\Program Files" #The starting folder to analyze #Variables that need to be set for each run You can set the starting folder location to analyze, which will help you avoid returning too much unnecessary information. Once you have the HTML file in place and you’re ready to try this, make sure to set the variables at the top of the below PowerShell code to accommodate your configuration. When complete, you can simply open the html file to view the results! With a quick scan of the file tree view, you’ll be able to see exactly which file(s) is taking up space. Once the html is produced, it will be inserted into an html file template that is covered in the next section. In order to do this, it is necessary to recursively (more detail on recursion) go through the folder structure and generate the html per folder. The PowerShell code below works by dynamically generating html that will produce the file directory tree view hierarchy. With a bit of PowerShell code (that I’ll share with you) and an HTML file, I’ll demonstrate how to create a tree view of your machine’s file structure – with a size breakdown included – so you can quickly find your space hog. No more clicking folder by folder, inspecting their properties, and determining folder size one by one. However, I recently coded a way to speed this process up with PowerShell. Tracking the culprit folder that was hogging up disk space used to be a troublesome, manual effort. As an admin of many server types, I often encounter the issue of a machine running out of disk space.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |