Solved

Script to get all mdb file details for list of servers

Posted on 2013-11-20
7
511 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
Are your end users making ugly email signatures?

Have you left it up to your end users to create their own email signatures? Are they forgetting to add the company logo or using garish font colors? Take control and ensure all users have the same email signature.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
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…
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…

863 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

17 Experts available now in Live!

Get 1:1 Help Now