|
| Hi,
I am trying to run the vb script to gether inventory s/w, h/w, user
info, network info etc., for windows 2000, xp, 2003 servers.
unfortunately i am not getting any reports generated while running. It
should give me the reports in .csv format.
same script works in my lab setup. but its not working the real
environment where I should run and take the reports of windows server.
initially am trying to run it on local system(desktop) with local admin
rights , for that itself it is not generating any report.
thinking this may be because of group policy restriction on the local
system.
can anyone help me in fixing this problem.
attaching the script for reference:
---------------------------
option explicit
'On Error Resume Next
dim compArray
dim InformationArray
dim InformationFileArray
dim oshell
dim tempFileName
dim Format
dim comp
dim Property_Information_File
dim Property_Information
dim i
dim objFSO,objFolder,strDate,TempFolder,strT
ime
Dim fso, f, ts, objFP, objFP1, tempStr, FileInput, FileOutput, counter,
opt
dim objFile, compList,objPing, machine,
objStatus,strComputer,objWMIService, colProcessList
opt = MsgBox (" Are you sure you want to run Inventory Manager v 1.2
?", vbYesNO+vbInformation, "Inventory Manager v 1.2")
If opt = vbYes Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
tempFileName = "computers.txt"
If Not objFSO.FileExists(tempFileName) Then
MsgBox "computers.txt file missing!",vbOkOnly+vbInformation, "Inventory
Manager v 1.2"
Wscript.Quit(1)
End If
strDate = Date
strDate = Replace(strDate,"/","_")
strTime= time
strTime = Replace(strTime,":","_")
strTime = Replace(strTime," ","_")
tempStr = strDate & "_" & strTime
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
TempFolder = "D_" & tempStr
If objFSO.FolderExists(TempFolder) Then
objFSO.DeleteFolder(TempFolder)
End If
Set objFolder = objFSO.CreateFolder(TempFolder)
call EnumComputers(compArray)
InformationArray=Array("group get caption, Description, LocalAccount,
Name, SID, SIDType, Status ","useraccount get Name, AccountType,
Caption, Description, LocalAccount, Lockout, PasswordChangeable,
PasswordExpires, PasswordRequired, SID, SIDType, Status
","softwarefeature get Accesses, Attributes, Description, Description,
IdentifyingNumber, InstallDate, InstallState, LastUse, ProductName ,
Vendor, Version ","nic get caption,AdapterType, AdapterTypeId,
MACAddress, Manufacturer, NetConnectionID /format:csv.xsl ","DiskDrive
get MediaType, Model, Name, Partitions ","computersystem get Domain,
TotalPhysicalMemory ","cpu get Name, ProcessorType, MaxClockSpeed
","printerconfig get caption, DriverVersion ")
InformationFileArray=Array("Group_Information.csv","User_Information.csv","Software_Information.csv","NetworkAdapterInformation.csv","Disk_Information.csv","RAM_Information.csv","Processor_Information.csv","Printer_Information.csv")
Format = "/Format:csv.xsl"
counter = uBound(compArray)
i=0
Set oShell = CreateObject ("WScript.shell")
For each comp in compArray
' comp = comparray(1)
For i=0 to UBound(InformationArray)
Property_Information_File = comp &"_" & InformationFileArray(i)
Property_Information = InformationArray(i)
call RunShell(Comp, Property_Information_File,
Property_Information, Format)
next
oShell.Popup comp & " finished. " & counter &" computers
remaining.",1,"Inventory Manager v 1.2"
counter = counter - 1
next
Call ProcessEnded()
Msgbox "Data collection complete. Please run conversion script present
inside folder " & TempFolder & " to format data."
,vbOkOnly+vbInformation,"Inventory Manager v 1.2"
Set oShell = Nothing
Set objFP = objFSO.GetFile("Conversion.vbs")
If Not objFSO.FileExists(TempFolder & "\" & "Conversion.vbs") Then
objFP.Copy TempFolder & "\"
End If
sub RunShell (Comp, Property_Information_File, Property_Information,
Format)
oShell.Run "wmic /node:"&Comp&"
/output:"&TempFolder&"\"&Property_Information_File&"
"&Property_Information&Format,7
end sub
For each comp in compArray
For i=0 to UBound(InformationArray)
Property_Information_File = comp &"_" & InformationFileArray(i)
next
next
Sub EnumComputers(compArray)
Const ForReading = 1
Set objFP = objFSO.OpenTextFile (tempFileName,ForReading,True)
Set compList = CreateObject("Scripting.Dictionary")
Do until objFP.AtEndOfStream
tempStr = objFP.ReadLine
machine = tempStr
machine = Replace(machine," ", "")
machine = Replace(machine,vbTab,"")
Set objPing = GetObject(" winmgmts:{impersonationLevel=impersonate
}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& machine & "'")
For Each objStatus in objPing
If Len(machine) <> 0 Then
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
compList.Add machine,"false"
Else
compList.Add machine,"true"
End If
End If
Next
Loop
objFP.Close
Set objFP = objFSO.CreateTextFile(TempFolder & "\" &
"FailedComputers.txt",true)
Set objFP1 = objFSO.CreateTextFile(TempFolder & "\" &
"PingedComputers.txt",true)
compArray = compList.Keys()
For Each comp in compArray
If compList.Item(comp) = "false" then
objFP.WriteLine comp
compList.Remove(comp)
Else
objFP1.WriteLine comp
End If
Next
objFP.Close
objFP1.Close
If UBound(compArray) < 0 Then
Msgbox "No computers to process! Please Check ""computers.txt"" file.",
vbOkOnly + vbInformation, "Inventory Manager v 1.2"
If objFSO.FolderExists(TempFolder) Then
objFSO.DeleteFolder(TempFolder)
End If
WScript.Quit
End If
End Sub
Sub ProcessEnded
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("Select * from
Win32_Process Where Name = 'wmic.exe'")
do until colProcessList.count = 0
Set colProcessList = objWMIService.ExecQuery("Select * from
Win32_Process Where Name = 'wmic.exe'")
loop
End Sub
End If
----------------------------------
|
|