Hello!
I’ve got Fileserver on Windows 2012, i have a script that get info:
- Top-30 largest files
- 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?
Hello!
I’ve got Fileserver on Windows 2012, i have a script that get info:
I need to get top-20 users that use more space on file storage then others.
Any ideas how to do it?
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.
Yeap, you;re right, here is my scripts:
$date=Get-Date -format yyyy-MM-dd $src="C:\shares\" $dst="C:\Shares\" $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} $a=0 $b=0 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 $a=$_.Owner $b=0 } }
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?
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’I hope it will be enough inspiration for you.$SizeReport = Get-ChildItem -Path $SharesRoot -Directory |
ForEach-Object {
[PSCustomObject]@{
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