I haven’t really keep up with this thread, but I recall seeing wmic, shell redirection, MAC Address, Drive SerialNumber, etc. Old code, revised a bit for this, only tested on Win7 & SU2017.
Maybe Win32Ole? If that’s okay, try the following:
# load '<path to this>'
require 'win32ole'
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
wmi = locator.ConnectServer(".", "/root/cimv2")
adapters = wmi.ExecQuery("Select * from Win32_NetworkAdapterConfiguration")
drives = wmi.ExecQuery("Select * from Win32_DiskDrive")
ctr = 0 ; item0 = nil
puts "\n#{'-' * 20} Adapter Info"
adapters.each { |net|
if net.MACAddress
item0 = net if ctr == 0 ; ctr += 1
puts "#{net.MACAddress} #{net.IPEnabled.to_s.ljust(6)} #{(net.IPAddress || []).join(' ')}"
end
}
if item0
puts "\n#{'-' * 20} Adapter Properties"
item0.properties_.each { |prop| puts prop.Name }
end
ctr = 0 ; item0 = nil
puts "\n#{'-' * 20} Drive Info"
drives.each { |drv|
if drv.SerialNumber
item0 = drv if ctr == 0 ; ctr += 1
puts "#{drv.SerialNumber.strip.ljust(20)} #{drv.Description.ljust(20)} #{drv.InterfaceType}"
end
}
if item0
puts "\n#{'-' * 20} Drive Properties"
item0.properties_.each { |prop| puts prop.Name }
end