Solved

Script to get all mdb file details for list of servers

Posted on 2013-11-20
7
506 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:lionelmm
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 24

Expert Comment

by:lionelmm
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now