Link to home
Start Free TrialLog in
Avatar of garcoli
garcoli

asked on

VBscript to audit machine info

Hi,

I need a VB script to interagate a list of computers in a text file , to see if the machine are on line, report the IP address , check for permission to C$, check if someone is logged in , the user of person logged in. all of above to be reported to a log file.

Many thanks,

Avatar of sirbounty
sirbounty
Flag of United States of America image

First portion should be easy enough (attached).
Need to know OS for some of the other stuff...?
Const InputFile = "C:\Computers.txt"
Const OutputFile = "C:\ComputerAudit.txt"

Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOut : Set objOut = objFSO.CreateTextFile (OutputFile)
Dim objShell : Set objShell = CreateObject("Wscript.Shell")

aryComputers = Split(objFSO.OpenTextFile(InputFile).ReadAll, vbNewLine)

For Each pc in aryComputers
  PingResults = PingTest (pc)
  objOut.Write pc & vbTab & Split(PingResults,vbNewLine)(0) & vbTab & Split(PingResults, vbNewLine)(1) & vbTab
Next

objOut.Close  

Function PingTest (strPC)
  If Trim(strPC) = "" Then
    PingTest = vbNewLine
    Exit Function
  End If
  Dim objExec : Set objExec = objShell.Exec ("ping -n 2 -w 1000 " & strPC)
  blnOnline = False
  IP = "0.0.0.0"
  strResults = lCase(objExec.StdOut.ReadAll)
  If Instr(strResults, "reply from") Then blnOnline = True
  Set objExec = objShell.Exec ("nslookup " & strPC)
  strResults = lCase(objExec.StdOut.ReadAll)
  IP = Trim(Mid(strResults, InstrRev(strResults, "address")+8))
  PingTest = blnOnline & vbNewLine & IP
End Function

Open in new window

Avatar of garcoli
garcoli

ASKER

OS is XP...thanks
Are you opposed to some 3rd party (free) tools?
I believe one of the only ways of getting the remote perms is via cacls/icacls/xcacls, but I'm not having luck with the former (native) tool...  I believe xcacls/icacls may pull this...
Avatar of garcoli

ASKER

No that is fine.
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of garcoli

ASKER

Hi,I am getting the following error in the attached document.

ScriptError.bmp