Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Huge file size, owner and age (last accessed) details - Powershell

Posted on 2014-08-29
9
Medium Priority
?
1,224 Views
Last Modified: 2014-09-10
We have 100+ file shares and each of them are 1.2 TB to 2 TB of size NAS volumes.

We would like to send a report large file size (>100 MB)  to users with the details of file name, directory name, size of the file, the owner of the file and last accessed information, may be also the age of file in days from last accessed.
something like below

FileName Directory                        Size (MB)    User ID                  Age (From Last access - Days)    Last Access Date
xyx.zip      F:\common\Finance\   304              DomainA\UserB  368                                                  11/23/2013 10:32 PM

I could get pieces of these information from powershell. But could not get into single script properly.

Appreciate your help.
0
Comment
Question by:Raj T
  • 5
  • 3
9 Comments
 
LVL 8

Expert Comment

by:Wilder_Admin
ID: 40292263
You should use the quote of your server, its already implemted and works well enough.

last access date Get-ChildItem c:\fso -File | select name, *time
0
 

Author Comment

by:Raj T
ID: 40292349
Thanks Wilder

Well due to our type of operations we cannot implement quota...Otherwise there is not second thought quota is better....
I have pieces of each feature I am looking for like how to check last access date etc...I am looking for one command /script to pull the five features I am looking for...
0
 
LVL 40

Expert Comment

by:Subsun
ID: 40292982
Here is a sample code which will get you the required result..
GCI "C:\TestFolder" -Recurse | 
 ? {!($_.PSIsContainer) -and $_.length -gt 100MB} |  %{
	New-Object PSobject -Property @{
		SizeinMB = [math]::Round(($_.Length / 1MB),2)
		AgeinDays = ((Get-Date) - $_.LastAccessTime).days
		LastAccessTime = $_.LastAccessTime
		Owner = (Get-Acl $_.Fullname).Owner
		Directory = $_.Directory
		FileName = $_.Name
	}
} | Select FileName,Directory,SizeinMB,AgeinDays,LastAccessTime,Owner |
Export-Csv C:\Report.csv -nti

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Raj T
ID: 40295560
Thanks a lot Subsun. It works well in my local PC. Only thing is it is taking the age from last modified date. It is not counting the read date. I tried opening a video file and tried running the script again. But the access date is not taken into consideration. It is show xx days old.

I will check in our NAS system to see how the access date and long directory names comes out.
0
 

Author Comment

by:Raj T
ID: 40296076
I tried running in NAS system today and it worked but few data is not coming.

1- Few owners data is blank. ( There are few SIDs and i understand those user IDs are removed from AD)
2- Some of them comes in as Built in Admins.
3- Long file/dir name > 260 char is not coming up
4- Last access date is still issue.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 40300478
Sorry, I'm travelling now. I will test this and let you know as I can..
0
 

Author Comment

by:Raj T
ID: 40302780
Sure...I am also travelling...I will also check further...
0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 40306714
1- Few owners data is blank. ( There are few SIDs and i understand those user IDs are removed from AD)
Do you want to display the SID ID instead of the empty line?

2- Some of them comes in as Built in Admins.
Mostly the file owner is local administrator.

3- Long file/dir name > 260 char is not coming up
PowerShell wont work with 260+ long file names. Give me some time, I will test an alternate method.

4- Last access date is still issue.
Probably the  Last Access Timestamp is disabled in your computer.
http://www.sevenforums.com/tutorials/243272-last-access-timestamp-enable-disable-windows.html
0
 

Author Closing Comment

by:Raj T
ID: 40314983
Thanks a lot Suban. Around 30 % files are long name.
0

Featured Post

Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
I’m willing to make a bet that your organization stores sensitive data in your Windows File Servers; files and folders that you really don’t want making it into the wrong hands.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.
Screencast - Getting to Know the Pipeline
Suggested Courses

578 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