-
-
Save datavudeja/5329ff52860d90088ef6839fb5a91216 to your computer and use it in GitHub Desktop.
show the size of the folders in current location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Get all directories in the current location | |
| $folders = Get-ChildItem -Directory | |
| # Iterate over each directory and calculate its size | |
| foreach ($folder in $folders) { | |
| $folderPath = $folder.FullName | |
| $size = (Get-ChildItem -Recurse -Force $folderPath | Measure-Object -Property Length -Sum).Sum | |
| $sizeMB = [math]::round($size / 1MB, 2) | |
| Write-Output "Folder: $folderPath, Size: $sizeMB MB" | |
| } | |
| # go to Windows PowerShell (Admin) | |
| # $scriptContent | Out-File -FilePath "C:\Users\UserName\GetFolderSizes.ps1" -Encoding UTF8 | |
| # .\GetFolderSizes.ps1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment