📜 VBScript (WSH)
Get Network Adapters Report to File (VBScript)
Queries Win32_NetworkAdapter via WMI and writes Network Adapters to a timestamped text file, handy for scheduled logon/logoff scripts.
GetNetworkAdapterReportToFile.vbs
' ============================================================
' GetNetworkAdapterReportToFile.vbs
'
' Reports Network Adapters via WMI (Win32_NetworkAdapter) and writes the results to a
' timestamped text file next to this script.
'
' Usage: cscript GetNetworkAdapterReportToFile.vbs
' ============================================================
Option Explicit
Dim objWMIService, colItems, objItem
Dim objFSO, objFile, strOutPath, itemCount
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT Name, MACAddress, AdapterType, NetEnabled FROM Win32_NetworkAdapter")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strOutPath = objFSO.GetParentFolderName(WScript.ScriptFullName) & "\networkadapter-report_" & _
Replace(FormatDateTime(Now, 2), "/", "-") & ".txt"
Set objFile = objFSO.CreateTextFile(strOutPath, True)
itemCount = 0
For Each objItem In colItems
objFile.WriteLine "Name: " & objItem.Name
objFile.WriteLine "MACAddress: " & objItem.MACAddress
objFile.WriteLine "AdapterType: " & objItem.AdapterType
objFile.WriteLine "NetEnabled: " & objItem.NetEnabled
objFile.WriteLine String(40, "-")
itemCount = itemCount + 1
Next
objFile.Close
WScript.Echo itemCount & " Network Adapters written to: " & strOutPath