Author Posts

July 7, 2017 at 9:38 am


I've got Fileserver on Windows 2012, i have a script that get info:

1. Top-30 largest files
2. Top-30 newest files

I need to get top-20 users that use more space on file storage then others.

Any ideas how to do it?

July 7, 2017 at 10:33 am

You could extend your script to show the top-20 users as well. 😉

It's not a free script shop here. We cannot write scripts for you or deliver ready to use solutions. If you have a specific problem with a particular piece of code you wrote you can post this here and the errors you might have and we can try to help you with this.

July 7, 2017 at 10:54 am

Yeap, you;re right, here is my scripts:

$date=Get-Date -format yyyy-MM-dd
$table = @{Expression={$_.Owner};Label="Process Name";width=25}, `
@{Expression={$_.SizeMB};Label="Process ID";width=15}, `
@{Expression={$_.MainWindowTitle};Label="Window Title";width=40}
If (Test-Path '$dst') {New-Item $dst -type directory}
gci -r $src -ea 0 |  Select-Object FullName ,@{n='Owner';e={(Get-Acl $_.fullname).Owner}}, CreationTime, Length | sort Owner -desc  | foreach {
if ( $_.Owner -eq $a ) {$b=$b+$_.Length 
else {
 write-host $a , $b

I get list of users, sort it by owner and then on every string i take owner and compare it with previous Owner. If it's the same, I summarize size. Else I write-host results.

It works ok, is it logically correct?

How can I add variables instaed of Write-Host to Table and export it to cvs?

July 7, 2017 at 11:43 am

OK ... sorry when I don't take your script and debug it. I think it's more helpful when I show how I would try to accomplish what you asked for and you adapt it to your special needs.

$SharesRoot = 'C:\shares\Sever Minerals\7.Marketing'

$SizeReport = Get-ChildItem -Path $SharesRoot -Directory |
    ForEach-Object {
            FolderName = $_.Name
            SizeInGB = [MATH]::Round((Get-ChildItem -Path $_.FullName -File -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object -Property length -Sum).Sum /1MB, 2)
            Owner = (Get-Acl $_.fullname).Owner
$SizeReport | Sort-Object -Property SizeInGB | Select-Object -First 20

I hope it will be enough inspiration for you. 😉