1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
| Dim strComputer As String, objWMIService As Object, colItems As Object, objItem As Object
Dim l As Long, t As String, HasBattery As Boolean
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
l = 30
Debug.Print String(60, "=")
Debug.Print "Alimentation sur batteries"
Debug.Print String(60, "=")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Battery")
For Each objItem In colItems
HasBattery = True
t = "Availability": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Availability)
t = "BatteryRechargeTime": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.BatteryRechargeTime)
t = "BatteryStatus": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.BatteryStatus)
t = "Caption": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Caption)
t = "Chemistry": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Chemistry)
t = "ConfigManagerErrorCode": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ConfigManagerErrorCode)
t = "ConfigManagerUserConfig": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ConfigManagerUserConfig)
t = "CreationClassName": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.CreationClassName)
t = "Description": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Description)
t = "DesignCapacity": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.DesignCapacity)
t = "DesignVoltage": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.DesignVoltage)
t = "DeviceID": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.DeviceID)
t = "ErrorCleared": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ErrorCleared)
t = "ErrorDescription": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ErrorDescription)
t = "EstimatedChargeRemaining": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.EstimatedChargeRemaining)
t = "EstimatedRunTime": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.EstimatedRunTime)
t = "ExpectedBatteryLife": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ExpectedBatteryLife)
t = "ExpectedLife": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ExpectedLife)
t = "FullChargeCapacity": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.FullChargeCapacity)
t = "InstallDate": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.InstallDate)
t = "LastErrorCode": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.LastErrorCode)
t = "MaxRechargeTime": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.MaxRechargeTime)
t = "Name": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Name)
t = "PNPDeviceID": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.PNPDeviceID)
For i = LBound(objItem.PowerManagementCapabilities) To UBound(objItem.PowerManagementCapabilities)
t = "PowerManagementCapabilities": Debug.Print t + Space(l - Len(t)) + ":" & CStr(objItem.PowerManagementCapabilities(i))
Next
t = "PowerManagementSupported": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.PowerManagementSupported)
t = "SmartBatteryVersion": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.SmartBatteryVersion)
t = "Status": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Status)
t = "StatusInfo": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.StatusInfo)
t = "SystemCreationClassName": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.SystemCreationClassName)
t = "SystemName": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.SystemName)
t = "TimeOnBattery": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.TimeOnBattery)
t = "TimeToFullCharge": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.TimeToFullCharge)
Next
If Not HasBattery Then Debug.Print " => Pas de batterie installée"
Debug.Print
HasBattery = False
Debug.Print String(60, "=")
Debug.Print "PortableBattery"
Debug.Print String(60, "=")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PortableBattery")
For Each objItem In colItems
HasBattery = True
t = "Availability": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Availability)
t = "BatteryRechargeTime": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.BatteryRechargeTime)
t = "BatteryStatus": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.BatteryStatus)
t = "CapacityMultiplier": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.CapacityMultiplier)
t = "Caption": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Caption)
t = "Chemistry": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Chemistry)
t = "ConfigManagerErrorCode": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ConfigManagerErrorCode)
t = "ConfigManagerUserConfig": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ConfigManagerUserConfig)
t = "CreationClassName": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.CreationClassName)
t = "Description": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Description)
t = "DesignCapacity": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.DesignCapacity)
t = "DesignVoltage": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.DesignVoltage)
t = "DeviceID": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.DeviceID)
t = "ErrorCleared": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ErrorCleared)
t = "ErrorDescription": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ErrorDescription)
t = "EstimatedChargeRemaining": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.EstimatedChargeRemaining)
t = "EstimatedRunTime": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.EstimatedRunTime)
t = "ExpectedBatteryLife": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ExpectedBatteryLife)
t = "AExpectedLife": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ExpectedLife)
t = "FullChargeCapacity": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.FullChargeCapacity)
t = "InstallDate": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.InstallDate)
t = "LastErrorCode": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.LastErrorCode)
t = "Location": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Location)
t = "ManufactureDate": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ManufactureDate)
t = "Manufacturer": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Manufacturer)
t = "MaxBatteryError": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.MaxBatteryError)
t = "MaxRechargeTime": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.MaxRechargeTime)
t = "Name": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Name)
t = "PNPDeviceID": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.PNPDeviceID)
For i = LBound(objItem.PowerManagementCapabilities) To UBound(objItem.PowerManagementCapabilities)
t = "PowerManagementCapabilities": Debug.Print t + Space(l - Len(t)) + ":" & CStr(objItem.PowerManagementCapabilities(i))
Next
t = "PowerManagementSupported": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.PowerManagementSupported)
t = "SmartBatteryVersion": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.SmartBatteryVersion)
t = "Status": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Status)
t = "StatusInfo": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.StatusInfo)
t = "SystemCreationClassName": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.SystemCreationClassName)
t = "SystemName": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.SystemName)
t = "TimeOnBattery": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.TimeOnBattery)
t = "TimeToFullCharge": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.TimeToFullCharge)
Next
If Not HasBattery Then Debug.Print " => Pas de gestion de batterie (!!!)"
Debug.Print
Debug.Print String(60, "=")
Debug.Print "Onduleur (installation managée)"
Debug.Print String(60, "=")
HasBattery = False
Set colItems = objWMIService.ExecQuery("Select * from Win32_UninterruptiblePowerSupply")
For Each objItem In colItems
HasBattery = True
t = "ActiveInputVoltage": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ActiveInputVoltage)
t = "Availability": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Availability)
t = "BatteryInstalled": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.BatteryInstalled)
t = "CanTurnOffRemotely": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.CanTurnOffRemotely)
t = "Caption": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Caption)
t = "CommandFile": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.CommandFile)
t = "ConfigManagerErrorCode": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ConfigManagerErrorCode)
t = "ConfigManagerUserConfig": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ConfigManagerUserConfig)
t = "CreationClassName": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.CreationClassName)
t = "Description": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Description)
t = "DeviceID": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.DeviceID)
t = "ErrorCleared": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ErrorCleared)
t = "ErrorDescription": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.ErrorDescription)
t = "EstimatedChargeRemaining": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.EstimatedChargeRemaining)
t = "EstimatedRunTime": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.EstimatedRunTime)
t = "FirstMessageDelay": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.FirstMessageDelay)
t = "InstallDate": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.InstallDate)
t = "IsSwitchingSupply": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.IsSwitchingSupply)
t = "LastErrorCode": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.LastErrorCode)
t = "LowBatterySignal": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.LowBatterySignal)
t = "MessageInterval": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.MessageInterval)
t = "Name": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Name)
t = "PNPDeviceID": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.PNPDeviceID)
t = "PowerFailSignal": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.PowerFailSignal)
For i = LBound(objItem.PowerManagementCapabilities) To UBound(objItem.PowerManagementCapabilities)
t = "PowerManagementCapabilities": Debug.Print t + Space(l - Len(t)) + ":" & CStr(objItem.PowerManagementCapabilities(i))
Next
t = "PowerManagementSupported": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.PowerManagementSupported)
t = "Range1InputFrequencyHigh": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Range1InputFrequencyHigh)
t = "Range1InputFrequencyLow": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Range1InputFrequencyLow)
t = "Range1InputVoltageHigh": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Range1InputVoltageHigh)
t = "Range1InputVoltageLow": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Range1InputVoltageLow)
t = "Range2InputFrequencyHigh": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Range2InputFrequencyHigh)
t = "Range2InputFrequencyLow": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Range2InputFrequencyLow)
t = "Range2InputVoltageHigh": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Range2InputVoltageHigh)
t = "Range2InputVoltageLow": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Range2InputVoltageLow)
t = "RemainingCapacityStatus": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.RemainingCapacityStatus)
t = "Status": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.Status)
t = "StatusInfo": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.StatusInfo)
t = "SystemCreationClassName": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.SystemCreationClassName)
t = "SystemName": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.SystemName)
t = "TimeOnBackup": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.TimeOnBackup)
t = "TotalOutputPower": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.TotalOutputPower)
t = "TypeOfRangeSwitching": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.TypeOfRangeSwitching)
t = "UPSPort": Debug.Print t + Space(l - Len(t)) + ":" & (objItem.UPSPort)
Next
If Not HasBattery Then Debug.Print " => Pas d'onduleur managé" |
Partager