做机器维护时,为偷懒方便不用去机房取服务器序列号可采用如下方法:
1、linux取序列号:
命令执行:dmidecode |grep "Serial Number"
2、windows取序列号:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT SerialNumber FROM Win32_BIOS")
For Each objItem In colItems
WScript.Echo "SerialNumber: " & objItem.SerialNumber
Next
或
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.InstancesOf("Win32_BIOS")
For Each objItem In colItems
WScript.Echo "SerialNumber: " & objItem.SerialNumber
Next
保存为get-sn.vbs,在windows下直接运行便可。
转载于:https://blog.51cto.com/lysweb/884973