Solved

Script to get all mdb file details for list of servers

Posted on 2013-11-20
7
518 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
[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
  • 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 25

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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.
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…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

730 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