Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks
'Option Explicit 'On Error Resume Next Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20 'Database connection string for SystemsInventory Const strConnect = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=SystemsInventory;Data Source=NAS-LCLSYDB01" 'Create database connection set adbConn = CreateObject("ADODB.Connection") 'Create Connection to the Record Set set adbRS = CreateObject("ADODB.RecordSet") 'Collect and store the following info for inventory: 'ComputerName set WshNetwork = WScript.CreateObject("WScript.Network") strComputerName = WshNetwork.ComputerName 'IP and MAC Address Set objWMIService = GetObject("winmgmts:\\" & strComputerName & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly) For Each objItem In colItems if not IsNull(objItem.IPAddress) Then strIPAddress = Join(objItem.IPAddress, ",") strNetwork = Left(strIPAddress,5) if strNetwork = "10.13" Then strRealIP = strIPAddress strMacAddress = objItem.MACAddress end if end if Next 'Time of Shutdown strShutDnTime = Date & " " & Time 'Open the Database Connection adbConn.open strConnect 'Open the Record Set for modification adbRS.Open "tbl_WoLInfo",adbConn,2,2 'Prepare records to insert adbRS.AddNew adbRS("ComputerName") = strComputerName adbRS("ShutDownTime") = strShutDnTime adbRS("IPAddress") = strRealIP adbRS("MacAddress") = strMacAddress 'Insert records adbRS.Update 'Close the Connections adbRS.Close adbConn.Close
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.