Solved

Need a VBscript that can scan all the folders for Created and modified files by variable date.

Posted on 2014-09-25
9
277 Views
Last Modified: 2014-10-25
I have a need to control a repository folder size with thousands of users using it. We need a VBscript that can scan all the folders for Created and modified file with in variable time periods. Such as last 24 hours. Add write out to file. Some teams are adding to many files and we just want to know who they are by reviewing there teams subfolder under the main teams repository folder.
0
Comment
Question by:williamfl
9 Comments
 

Author Comment

by:williamfl
ID: 40344288
We would like the output file to show the file sizes also so we can identify the team using the most space.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 40345455
Using Powershell would be the best option here.  There's a good article here:
http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/25/getting-directory-sizes-in-powershell.aspx

that should give you something close to what you need.

Rob.
0
 
LVL 29

Expert Comment

by:becraig
ID: 40345464
gci  c:\folder -recurse | where {(!($_.PsIsContainer)) -and $_.CreationTime -gt (Get-Date).AddDays(-1)} | select Fullname, Length | export-csv report.csv -ntigci c:\folder -recurse  | {where $_.CreationTime - lt (get-Date).AddDays(-1)}

Open in new window

0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 70

Expert Comment

by:Chris Dent
ID: 40345492
Bit messy on the end of your example there becraig, copy and paste problems by the looks of it. It might be a good idea to repost it.

I would add that:

> with thousands of users using it

You'll almost certainly hit the native path length limitation in .NET (260 characters). It's possible to work-around the limitation by creating temporary drive mappings or junctions, it's just quite deeply unpleasant (in my opinion).

Chris
0
 
LVL 29

Accepted Solution

by:
becraig earned 500 total points
ID: 40345508
Very true Chris :~)

Methinks some sleep is needed:

Here is a cleaned up version:
gci  -recurse | where {(!($_.PsIsContainer)) -and $_.CreationTime -gt (Get-Date).AddDays(-1)} | % {
$report = New-Object PSObject
$report | Add-Member -membertype NoteProperty -Name FileName -Value $_.Name
$report | Add-Member -membertype NoteProperty -Name ParentFolder -Value $_.DirectoryName
$report | Add-Member -membertype NoteProperty -Name Size -Value (("{0:N4}" -f ($_.length / 1MB) + "MB"))
}
$report | export-csv reports.csv -NoTypeInformation

Open in new window

0
 
LVL 45

Expert Comment

by:aikimark
ID: 40345849
You could also use Robocopy
Example:
robocopy sourcepath andvalidpath /L /minage:0 /maxage:1

Open in new window

0
 
LVL 29

Expert Comment

by:becraig
ID: 40346318
Ok I'm awake now:

I've added the file owner/creator as well as the option for files modified in the past day as well as files created in the past day.

A quick overview of what the powershell script below does:
The first line gci -recurse checks the current folder and all child folders (You need to replace "gci  -recurse " with "gci \\share\folder -recurse")
The output is piped into a foreach loop and the output objects are created then piped to the export-csv command.


gci  -recurse | where {(!($_.PsIsContainer)) -and ($_.CreationTime -gt (Get-Date).AddDays(-1) -or $_.LastWriteTime  -gt (Get-Date).AddDays(-1))} | % {
$report = New-Object PSObject
$report | Add-Member -membertype NoteProperty -Name Owner ((Get-ACL $_.FullName).Owner)
$report | Add-Member -membertype NoteProperty -Name FileName -Value $_.Name
$report | Add-Member -membertype NoteProperty -Name ParentFolder -Value $_.DirectoryName
$report | Add-Member -membertype NoteProperty -Name Size -Value (("{0:N4}" -f ($_.length / 1MB) + "MB"))
}
$report | export-csv reports.csv -NoTypeInformation

Open in new window

0
 
LVL 29

Expert Comment

by:becraig
ID: 40347682
Have you tested the script ?

Are there any issues to address ?
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Set OWA language and time zone in Exchange for individuals, all users or per database.
A brief introduction to what I consider to be the best editor for PowerShell.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

774 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