Audit My Documents Size on Local machines to plan for Folder Redirecttion

Hi All

We are planning to redirect our users My Documents to a file server, however prior to doing this i would like to know how much data we are going to end up with, is there a script that can go out to each PC and report back the size of the my documents folder, 95% of our estate is Windows 7 so  mostly concerned with this O/S,

Thanks
LVL 5
ncomperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

merowingerCommented:
Check out this article. The guy has the same question.
http://forums.petri.com/showthread.php?t=43178
footechCommented:
I haven't tested except on a local machine, but should work.
Using PS Remoting...
$computers = Get-Content computerlist.txt
$scriptblock = {
    Get-ChildItem c:\users | Get-ChildItem -filter "documents" |
     Get-ChildItem -Recurse -force -ea SilentlyContinue |
     Where { !($_.PsIsContainer) } |
     Select -expand length |
     Measure-Object -Sum |
     Select sum
}
Invoke-Command -ComputerName $computers -ScriptBlock $scriptblock | Export-CSV DocumentsSize.csv -notype

Open in new window

ncomperAuthor Commented:
Thanks, does anything need to be enabled on the remote client machine, it runs on mine OK but not remote PC's (firewall etc is off)

Also is it possible to get the path in export so we know the user?

Thanks
footechCommented:
Yes, PS Remoting needs to be enabled on all the target machines.
http://blogs.technet.com/b/heyscriptingguy/archive/2012/07/24/an-introduction-to-powershell-remoting-part-two-configuring-powershell-remoting.aspx
This will be much faster than using UNC paths.

If you're only concerned with the total amount of space required then I wouldn't think you'd be as concerned about each user.  I was also thinking that you probably only have one main user for each machine, however, perhaps that isn't the case.
Here's a revised script with the path included.
$computers = Get-Content complist.txt
$scriptblock = {
    Get-ChildItem c:\users | Get-ChildItem -filter "documents" | ForEach `
    {
         $path = $_.FullName
         Get-ChildItem $path -Recurse -force -ea SilentlyContinue |
         Where { !($_.PsIsContainer) } |
         Select -expand length |
         Measure-Object -Sum |
         Select @{n="Size";e={$_.sum}},@{n="Path";e={$path}}
    }
}
Invoke-Command -ComputerName $computers -ScriptBlock $scriptblock |
 Select PsComputerName,Size,Path |
 Export-CSV DocumentsSize.csv -notype

Open in new window


BTW, the .CSV generated is really just a data store for the information gathered.  It's still necessary to do your analysis to get the aggregate data you want according to your needs and tools available.  Here's an example of just summing all the sizes together with a little formatting.
$totalsize = Import-CSV DocumentsSize.csv |
 Select -expand Size |
 Measure-Object -Sum
"Total size: {0:N2} MB" -f ($totalsize.sum / 1MB)

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ncomperAuthor Commented:
Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.