Tilpasning af spcript
hej jeg er faldet over et inventory script som lige kan alt det jeg vil have det til UNtagen 1 ting. den "samler" kun en ip adresse og 1 mac adresse dvs hvis du har 3 Nic i din maskine så tager den kun 1 af dem. er der nogen af jer kloge hoveder der kan tilpasse dette?' Comments: This script is designed to be run from a logon script and enter details into an access database.
' Datasource need to be changed to reflect location and name of database.
'
' Database Fields: ComputerName Text 255
' Model Text 255
' Vendor Text 255
' Serial Text 255
' Version Text 255
' CPU Text 255
' Speed Text 255
' MonitorManufacturer Text 255
' MonitorModel Text 255
' VideoRAM Number Long Integer
' VideoCard Text 255
' VideoMode Text 255
' OS Text 255
' SP Text 255
' Asset Text 255
' CDrive Text 255
' CFreeSpace Number Long Integer
' CTotalSpace Number Long Integer
' DDrive Text 255
' DFreeSpace Number Long Integer
' DTotalSpace Number Long Integer
' CD Text 255
' CDDescription Text 255
' RAM Number Long Integer
' NetworkCard Text 255
' MAC Text 255
' User Text 255
' Date Date/Time Short Date
' Time Date/Time Medium Time
' ********** Global Declarations **********
Dim strComputerName ' The Computer Name to be queried via WMI
Dim strWinMgt ' The WMI management String
Dim objCon ' A Connection Object for database connectivity
Dim objRS ' A Recordset Object for database connectivity
Dim sProviderName ' The OLE Provider Type
Dim iCursorType ' The Cursor Type for the Recordset
Dim iLockType ' The Lock Type for the Recordset
Dim sDataSource ' The name and location of the database
Dim intRam ' The amount of RAM in the computer.
Dim CompSysSet
Dim CompSys
strComputerName = "."
strWinMgt = "winmgmts://" & strComputerName &""
'********** Beginning of Main Code **********
'
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_ComputerSystem")
For Each CompSys In CompSysSet
strName = CompSys.Name
Next
Call subConnectionOpen
strCriteria = "ComputerName = '"& strName &"'"
objRS.Find strCriteria
If objRS.EOF Then
Call subGetComputerInfo
Else
Call subDeleteRecord
Call SubGetComputerInfo
End If
Call subConnectionClose
'********** End of Main Code **********
'********** Beginning of Sub routine to Open database **********
Sub subConnectionOpen
Set objCon = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
sProviderName = "Microsoft.Jet.OLEDB.4.0"
iCursorType = 1
iLockType = 3
''''''''''''Change the following line to refelct correct DB location and name'''''''''''
sDataSource = "\\nt6135\c$\Inventory.mdb"
objCon.Provider = sProviderName
objCon.Properties("Data Source") = sDataSource
objCon.Open
objRS.CursorType = iCursorType
objRS.LockType = iLockType
objRS.Source = "Computerinfo"
objRS.ActiveConnection = objCon
objRS.Open
End Sub
'********** End of sub routine to Open database **********
'********** Beginning of Sub routine to Close database **********
Sub subConnectionClose
Set objRS = Nothing
Set objCon = Nothing
End Sub
'********** End of Sub routine to Close database **********
'********** Beginning of Sub routine to delete record **********
Sub subDeleteRecord
objRS.Delete
objRS.Update
End Sub
'********** End of Sub routine to delete record **********
'********** Beginning of Sub routine to get & write computer info **********
Sub subGetComputerInfo
' Get Model, Manufacturer, Computername and Memory
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_ComputerSystem")
For Each CompSys In CompSysSet
strModel = CompSys.Model
ComputerName = CompSys.Name
strVendor = CompSys.Manufacturer
intRAM = Clng(CompSys.TotalPhysicalMemory/1048576 )
Next
' Get BIOS info
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_BIOS")
For Each CompSys In CompSysSet
strSerial = CompSys.SerialNumber
strVersion = CompSys.Version
Next
' Get CPU info
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_Processor")
For Each CompSys In CompSysSet
strCPU = CompSys.Name
' StrSpeed = CompSys.CurrentClockSpeed
StrSpeed = CompSys.MaxClockSpeed
Next
' Get Monitor Info
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_DesktopMonitor")
For Each CompSys In CompSysSet
strMonManufacturer = CompSys.MonitorManufacturer
strMonModel = CompSys.Description
Next
' Get Video Card Info
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_VideoController")
For Each CompSys In CompSysSet
strVidRAM = CompSys.AdapterRAM/1024
strVidCard = CompSys.Description
strVidMode = CompSys.VideoModeDescription
Next
' Get OS Info
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_OperatingSystem")
For Each CompSys In CompSysSet
strOS = CompSys.Caption
strSP = CompSys.CSDVersion
Next
' Get Asset Tag Info
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_SystemEnclosure")
For Each CompSys In CompSysSet
strAsset = CompSys.SMBIOSAssetTag
Next
' Get Disk Information for C drive
'
Set DiskSet = GetObject(strWinMgt).ExecQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DeviceID = 'C:' and DriveType=3")
For Each Disk In DiskSet
Rem strDisplayDiskInfo = strDisplayDiskInfo & "Drive " & Disk.Name & " Free Space: " & Clng(Disk.FreeSpace/1000000) & " MB Total Size: " & Clng(Disk.Size/1000000) & " MB"& vbCrlf
strCDriveLetter = Left(disk.name,2)
strCFreeSpace = Disk.FreeSpace/2^30
strCTotalSpace = Disk.Size/2^30
Next
' Get Disk Information for D drive
'
Set DiskSet = GetObject(strWinMgt).ExecQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DeviceID = 'D:' and DriveType=3")
For Each Disk In DiskSet
Rem strDisplayDiskInfo = strDisplayDiskInfo & "Drive " & Disk.Name & " Free Space: " & Clng(Disk.FreeSpace/1000000) & " MB Total Size: " & Clng(Disk.Size/1000000) & " MB"& vbCrlf
strDDriveLetter = Left(disk.name,2)
strDFreeSpace = Disk.FreeSpace/2^30
strDTotalSpace = Disk.Size/2^30
Next
' Get Network Card Info
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_NetworkAdapterConfiguration where IPEnabled = 'TRUE'")
For Each CompSys In CompSysSet
strMAC = CompSys.MACAddress
strIPAddress = CompSys.IPAddress(i)
strNICModel = CompSys.Description
Next
' Get User Info
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_ComputerSystem")
For Each CompSys In CompSysSet
strUser = CompSys.UserName
Next
' Get CD Info
'Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_CDROMDrive")
'For Each CompSys In CompSysSet
'strCD = CompSys.Drive
'strCDDescription = CompSys.Name
'If you want to run manually and enter a descriptive note, uncomment the following line'
'strNote = InputBox("Please enter a note:")
'Next
objRS.AddNew
objRS("ComputerName") = strName
objRS("Note") = strNote
objRS("Model") = strModel
objRS("Vendor") = strVendor
objRS("Serial") = strSerial
objRS("Version") = strVersion
objRS("CPU") = strCPU
objRS("Speed") = strSpeed
objRS("MonitorManufacturer") = strMonManufacturer
objRS("MonitorModel") = strMonModel
objRS("VideoRAM") = strVidRAM/1024
objRS("VideoCard") = strVidCard
objRS("VideoMode") = strVidMode
objRS("OS") = strOS
objRS("SP") = strSP
objRS("Asset") = strAsset
objRS("CDrive") = strCDriveLetter
objRS("CFreeSpace") = strCFreeSpace
objRS("CTotalSpace") = strCTotalSpace
objRS("DDrive") = strDDriveLetter
objRS("DFreeSpace") = strDFreeSpace
objRS("DTotalSpace") = strDTotalSpace
objRS("CD") = strCD
objRS("CDDescription") = strCDDescription
objRS("RAM") = intRAM
objRS("NetworkCard") = strNICModel
objRS("MAC") = strMAC
objRS("IPAddress")= strIPAddress
objRS("User") = strUser
objRS("Date") = Date()
objRS("Time") = Time()
objRS.Update
objRS.Close
End Sub
'********** End of Sub routine to get & write computer info **********
'*****************************************************************************************