获取远程服务器的BIOS信息

时间:2019-05-31 13:40:49

标签: python

我已经写了一个代码来获取BIOS信息。目前,我正在为笔记本电脑执行此操作。

需要帮助才能在远程计算机上执行此操作

import win32com.client
import wmi
strComputer = "."

objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")
colItems = objSWbemServices.ExecQuery("Select * from Win32_BIOS")
for objItem in colItems:
    z = objItem.BiosCharacteristics
    if z is None:
        a = 1
    else:
        for x in z:
            print("Bios Characteristics: ", x)
    z = objItem.BIOSVersion
    if z is None:
        a = 1
    else:
        for x in z:
            print("BIOS Version: ", x)
    print("BIOS Version: ", objItem.BIOSVersion)
    print("Build Number: ", objItem.BuildNumber)
    print("Caption: ", objItem.Caption)
    print("Code Set: ", objItem.CodeSet)
    print("Current Language: ", objItem.CurrentLanguage)
    print("Description: ", objItem.Description)
    print("Identification Code: ", objItem.IdentificationCode)
    print("Installable Languages: ", objItem.InstallableLanguages)
    print("Install Date: ", objItem.InstallDate)
    print("Language Edition: ", objItem.LanguageEdition)
    z = objItem.ListOfLanguages
    if z is None:
        a = 1
    else:
        for x in z:
            print("List Of Languages: ", x)
    print("List Of Languages: ", objItem.ListOfLanguages)
    print("Manufacturer: ", objItem.Manufacturer)
    print("Name: ", objItem.Name)
    print("Other Target OS: ", objItem.OtherTargetOS)
    print("Primary BIOS: ", objItem.PrimaryBIOS)
    print("Release Date: ", objItem.ReleaseDate)
    print("Serial Number: ", objItem.SerialNumber)
    print("SMBIOS BIOS Version: ", objItem.SMBIOSBIOSVersion)
    print("SMBIOS Major Version: ", objItem.SMBIOSMajorVersion)
    print("SMBIOS Minor Version: ", objItem.SMBIOSMinorVersion)
    print("SMBIOS Present: ", objItem.SMBIOSPresent)
    print("Software Element ID: ", objItem.SoftwareElementID)
    print("Software Element State: ", objItem.SoftwareElementState)
    print("Status: ", objItem.Status)
    print("Target Operating System: ", objItem.TargetOperatingSystem)
    print("Version: ", objItem.Version)

我尝试用单独的代码连接到远程计算机,并且可以正常工作。

connection = wmi.connect_server(server="10.99.xx.xx", user="xxxx", password="xxxx")
c = wmi.WMI(wmi=connection)

请指导我如何合并两个代码以使其正常工作。

0 个答案:

没有答案