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

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.
Raj TAsked:
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.

Wilder_AdminCommented:
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
Raj TAuthor Commented:
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
SubsunCommented:
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
ON-DEMAND: 10 Easy Ways to Lose a Password

Learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees in this on-demand webinar. We cover the importance of multi-factor authentication and how these solutions can better protect your business!

Raj TAuthor Commented:
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
Raj TAuthor Commented:
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
SubsunCommented:
Sorry, I'm travelling now. I will test this and let you know as I can..
0
Raj TAuthor Commented:
Sure...I am also travelling...I will also check further...
0
SubsunCommented:
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

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
Raj TAuthor Commented:
Thanks a lot Suban. Around 30 % files are long name.
0
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
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.