williamfl
asked on
Need a VBscript that can scan all the folders for Created and modified files by variable date.
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.
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.
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.
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)}
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You could also use Robocopy
Example:
Example:
robocopy sourcepath andvalidpath /L /minage:0 /maxage:1
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.
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
Have you tested the script ?
Are there any issues to address ?
Are there any issues to address ?
ASKER