Query Directory Sizes


hello,

the below script query's drive , results largest fies in $path, excellent.

2 questions, results seem quite spread apart, there way ensure filename, size , directory fit without having scroll right, think main issue filename field spreading out way far , pushing size column off screen.

secondly, how add exceptions paths on here, don't want query c:\windows , else... ideas?

$path = "\\$global:compname\c$"
$size = 100mb
$limit = 30
$largesizefiles = get-childitem -path $path -recurse -erroraction "silentlycontinue" | ? { $_.gettype().name -eq "fileinfo" } | where-object {$_.length -gt $size} | sort-object -property length -descending | select-object name, @{name="sizeinmb";expression={$_.length / 1mb}},@{name="path";expression={$_.directory}} -first $limit
$largesizefiles | out-host -paging

hi,

get-childitem -exclude not working advertised when used on root folder.

the -exclude param works fine on normal folders not on root drives

you can use 1 of following options:

$path= get-childitem c: | {$_.psiscontainer -eq $true -and $_.name -ne "windows"}  #or skip $path part , use following $largesizefiles= get-childitem c:\* -exclude windows -recurse #rest of pipeline

 



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

CRL Revocation always failed

Failed to query the results of bpa xpath

0x300000d errors in Microsoft Remote Desktop client