May 30 2020 05:46 AM - edited May 30 2020 05:48 AM
Hi Guys, I do have bunch of target folders that I'm trying to check them regularly via PS script;
RootFolder\AAAA0001\Apps\...
RootFolder\BBBB0001\Apps\...
RootFolder\CCC00001\Apps\...
RootFolder\DDDD0001\Apps\...
goes on
I wanna get an output something like this
Ref AppFolderSize(GB)
AAAA0001 3GB
BBBB0001 2GB
CCCC0001 5GB
DDDD0001 8GB
etc.
Has someone done this?
Jun 02 2020 11:39 AM
@MichaelNazli I think this should help you.
$FoldersInRootFolder = Get-ChildItem -Path '\RootFolder\AAAA0001' -Directory -ErrorAction SilentlyContinue
$Results = @()
ForEach($Folder in $FoldersInRootFolder)
{
$Childs = Get-ChildItem -Path $Folder.FullName -Recurse -Force -ErrorAction SilentlyContinue
$Sum = 0
ForEach($Child in $Childs)
{
$Sum = $Child.Length + $Sum
}
$SumMB = $Sum / 1GB
$Props = [ordered]@{
Ref = $Folder.Name
"AppFolderSize(GB)" = $([math]::Round($SumMB,2))
}
$Results += New-Object PSObject -Property $Props
}
$Results
Regards
Erick Moreno
Jun 04 2020 06:47 PM
Thanks @Erick A. Moreno R.
I'll give it a go :)
Jun 28 2020 03:20 PM - edited Jun 28 2020 03:26 PM
Solution
dir c:\RootFolder -dir |
ft name,@{Label=”AppFolderSize(GB)”;Expression= {“{0:n2} GB” -f ((dir -rec $_|measure length -sum -ErrorAction SilentlyContinue).sum /1gb)}}
@MichaelNazli the script above is a single line of code and the output will be something like this:
Name AppFolderSize(GB)
---- -----------------
kkk 0,00 GB
m 2,54 GB
office2019-last 1,88 GB
symbols 0,00 GB
up2 0,00 GB
uplanner 0,00 GB
bye Gas