Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need assistance with powershell report

Posted on 2010-09-18
4
Medium Priority
?
1,313 Views
Last Modified: 2012-06-27
Please help as I am a newbie and pulling my hair out. What I am trying to accomplish is the report to display like the example below. I need a script that will display the total size of files owned by a user. Something like this below.

User      Total size
Userx      500mb
userT      1GB
Usera          40KB


What I have come up thus far is this.

$total_count
Get-childitem -recurse \\servername\share | foreach-object { $total_count += $_.Length }
$total_count

This produces the total size of the files but here is another issue. You see Get-acl gets the owner
of the file which is great. I just cannot seem to pipe these commands together to get this information. Get-childitem from what I can tell does not have the capability to get the file owner unless I am wrong.

I am also hoping to specify if its kb based on the size, then mb based on a size and then GB. This is purely cosmetic and not really that important. I am just having trouble getting the above to show.
0
Comment
Question by:tdodd72
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
Blake_1 earned 1000 total points
ID: 33710547
$hashTotal = @{}
Get-ChildItem -Recurse \\server\share | foreach {
    $objOwner = (Get-ACL $_.FullName).Owner
    $hashTotal[$objOwner] += $_.Length
}
$hashTotal
0
 

Author Comment

by:tdodd72
ID: 33710846
FYI: After running this script I keep getting this error below and the script just looks at me while it hangs.


Index operation failed; the array index evaluated to null.
At line:3 char:16
+     $hashTotal[ <<<< $objOwner] += $_.Length
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

Index operation failed; the array index evaluated to null.
At line:3 char:16
+     $hashTotal[ <<<< $objOwner] += $_.Length
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

Index operation failed; the array index evaluated to null.
At line:3 char:16
+     $hashTotal[ <<<< $objOwner] += $_.Length
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

Index operation failed; the array index evaluated to null.
At line:3 char:16
+     $hashTotal[ <<<< $objOwner] += $_.Length
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

Index operation failed; the array index evaluated to null.
At line:3 char:16
+     $hashTotal[ <<<< $objOwner] += $_.Length
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

Index operation failed; the array index evaluated to null.
At line:3 char:16
+     $hashTotal[ <<<< $objOwner] += $_.Length
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

Index operation failed; the array index evaluated to null.
At line:3 char:16
+     $hashTotal[ <<<< $objOwner] += $_.Length
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

Index operation failed; the array index evaluated to null.
At line:3 char:16
+     $hashTotal[ <<<< $objOwner] += $_.Length
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

Index operation failed; the array index evaluated to null.
At line:3 char:16
+     $hashTotal[ <<<< $objOwner] += $_.Length
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
0
 
LVL 5

Expert Comment

by:Blake_1
ID: 33710872
Are you using Powershell 2.0?  If you're not sure, it is reported if you type 'Get-Host'.  (NB v2 is also in a folder underneath 'v1.0')
0
 

Author Closing Comment

by:tdodd72
ID: 33712121
I found the issue and thank you sir for your help. My permissions were not propogated down the fileshare properly. Thanks a million for your help. The script ran and it looks sweet.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A procedure for exporting installed hotfix details of remote computers using powershell
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question