Solved

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

Posted on 2014-09-25
9
279 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
[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
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
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 
LVL 71

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
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…

763 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