Solved

Script to get all mdb file details for list of servers

Posted on 2013-11-20
7
513 Views
Last Modified: 2014-04-04
Hi,

We need a script to get the list of all the files with extension mdb residing on the list of servers. We need the below listed attributes for all the files found in the excel format

1) Server on which they are found
2) location of the file
3) Name of the file
4) extension of the file
5) Date last modified of the file
6) Date last accessed
7) Size of the file

We have below script however it is not able to get the date last modified and date last accessed

On Error Resume Next

'open the file system object
Set FSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")

Set Stream = FSO.OpenTextFile("C:\ServerList.txt")
computers = Split(Stream.ReadAll, vbNewLine)
Stream.Close

OutputFilePath="C:\Output.txt"

Set oReportFile = FSO.CreateTextFile(OutputFilePath, True)

For Each computer In computers
  Set objWMIService = GetObject("winmgmts:\\" & computer & "\root\cimv2")

  Set colFiles = objWMIService. _
      ExecQuery("Select * From CIM_DataFile Where Extension = 'MDB' ")


  If colFiles.Count = 0 Then
        Wscript.Echo "no exe files found"
            oReportFile.WriteLine(computer& "," & "No EXE File Found :)")

  Else
    For Each oFile in colFiles
var objfile = fso.getfile(oFile)
      oReportFile.WriteLine(computer & "!" & oFile.FileName & "!" & OFile.Path & "!" & OFile.drive & "!" & objFile.Extension  & "!" & Ofile.filesize)

        Next
  End If
Next
Set FSO=nothing
0
Comment
Question by:biplabmukh
  • 4
  • 2
7 Comments
 

Author Comment

by:biplabmukh
ID: 39663589
will appreciate a prompt response as need to prepare this report for management
0
 
LVL 24

Expert Comment

by:Lionel MM
ID: 39665640
If everything else is working as you want it you can add suggestions from this link -- will give you some ideas on how to get the the date modified info. http://www.tek-tips.com/viewthread.cfm?qid=1602861 and these two links for last accessed
http://steves-rant.blogspot.com/2006/11/last-accessed-vbs-script.html
http://ns7.webmasters.com/caspdoc/html/vbscript_file_object_datelastaccessed_property.htm
0
 

Author Comment

by:biplabmukh
ID: 39667084
however not able to successfully insert the function to get the last modified file

is it possible to integrate the scripts shared by you in the above script to get the dat last modified ?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 24

Expert Comment

by:Lionel MM
ID: 39667929
You can take pieces and parts and combine them. What happens when you try to insert the required functions. Please re-post your new code and the results--thanks.
0
 

Author Comment

by:biplabmukh
ID: 39668715
when i am running the below modified script it is running but writing nothing in the output file. However, when i replace the

below part

    "  oReportFile.WriteLine(computer & "!" & oFile.FileName & "!" & OFile.Path & "!" & OFile.drive & "!" & objFile.DateLastModified  & "!" & Ofile.filesize) "

with below :-

    Wscript.Echo "Creation date: " & oFile.CreationDate
    Wscript.Echo "Computer system name: " & oFile.CSName
    Wscript.Echo "Drive: " & oFile.Drive
    Wscript.Echo "Extension: " & oFile.Extension
    Wscript.Echo "File name: " & oFile.FileName
    Wscript.Echo "File size: " & oFile.FileSize
    Wscript.Echo "File type: " & oFile.FileType
    Wscript.Echo "File system name: " & oFile.FSName
    Wscript.Echo "Last accessed: " & oFile.LastAccessed
    Wscript.Echo "Last modified: " & objFile.LastModified

it is showing the last access and last modified information correctly but it is not writing it out, any idea why it is behaving like this ?

in output file it just write nothing
0
 
LVL 2

Accepted Solution

by:
daniel0 earned 500 total points
ID: 39677538
0
 

Author Closing Comment

by:biplabmukh
ID: 39978735
thanks for sharing the input.
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

803 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