Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Inspired from ERIC COBB's script
- $ErrorActionPreference= 'silentlycontinue'
- $disk = Get-PSDrive S
- "Disk size : " + "{0:N2}" -f ($disk.Used / 1GB) + " GB" + " -- Free space : " + "{0:N2}" -f ($disk.Free / 1GB) + " GB"
- $startDirectory = 'S:\'
- $directoryItems = Get-ChildItem $startDirectory | Where-Object {$_.PSIsContainer -eq $true} | Sort-Object
- foreach ($i in $directoryItems)
- {
- $subFolderItems = Get-ChildItem $i.FullName -recurse -force | Where-Object {$_.PSIsContainer -eq $false} | Measure-Object -property Length -sum | Select-Object Sum
- if ( $subFolderItems.sum / 1GB -gt 0.01)
- {
- $i.FullName + " -- " + "{0:N2}" -f ($subFolderItems.sum / 1GB) + " GB"
- }
- else
- {
- $i.FullName + " -- " + "{0:N2}" -f ($subFolderItems.sum / 1MB) + " MB"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement