List application data folder for multiple users powershell

326 Views Asked by At

We are having issue with folder redirection and want to split this up among two servers instead of one. One of the folders we are redirecting is the Application Data folder. We want to enumerate this folder for each user so we can decide how big the new shared volume should be. Is there a way to do this in power shell?

1

There are 1 best solutions below

2
Little King On

Recursive loops my friend. Perhaps someone has a better idea, but this was my approach. The output is also fun to watch :)

EDIT: $total is in BYTES. Be sure to do the conversion to what you need.

$total = 0 function Get-Childrens{ param($fullName) Get-ChildItem $fullName | foreach{ if((Get-Item $_.FullName).VersionInfo.FileName){ Write-Host $_.FullName $total += (Get-Item $_.FullName).Length }else{ Write-Host $_.FullName -ForegroundColor Green Get-Childrens $_.FullName } } } Get-Childrens "C:\Users\username\AppData\"