Script WMI

Le
Info
Bonjour,

Je recherche le moyen de faire un filtre WMI pour une GPO en récupérant
l'adresse IP des ordinateurs.
Je ne trouve pas la classe ou la méthode pour récupérer l'adresse IP.
Est-ce que quelqu'un pourrait m'aider ?

En vous remerciant par avance,
Vidéos High-Tech et Jeu Vidéo
Téléchargements
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
Jonathan BISMUTH
Le #656863
Bonjour,

pas un gros problème en fait. Tu peux t'aider du scriptomatic pour trouver
les bonnes classes WMI.
En l'occurence Win32_NetworkAdapterConfiguration.

Exemple ici de ce que l'on peut tirer de la classe :

' ## Debut du script, greets to scripting guys ###
On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("MonOrdinateur")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="

Set objWMIService = GetObject("winmgmts:\" & strComputer &
"rootCIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_NetworkAdapterConfiguration", "WQL", _
wbemFlagReturnImmediately +
wbemFlagForwardOnly)

For Each objItem In colItems
WScript.Echo "ArpAlwaysSourceRoute: " & objItem.ArpAlwaysSourceRoute
WScript.Echo "ArpUseEtherSNAP: " & objItem.ArpUseEtherSNAP
WScript.Echo "Caption: " & objItem.Caption
WScript.Echo "DatabasePath: " & objItem.DatabasePath
WScript.Echo "DeadGWDetectEnabled: " & objItem.DeadGWDetectEnabled
strDefaultIPGateway = Join(objItem.DefaultIPGateway, ",")
WScript.Echo "DefaultIPGateway: " & strDefaultIPGateway
WScript.Echo "DefaultTOS: " & objItem.DefaultTOS
WScript.Echo "DefaultTTL: " & objItem.DefaultTTL
WScript.Echo "Description: " & objItem.Description
WScript.Echo "DHCPEnabled: " & objItem.DHCPEnabled
WScript.Echo "DHCPLeaseExpires: " &
WMIDateStringToDate(objItem.DHCPLeaseExpires)
WScript.Echo "DHCPLeaseObtained: " &
WMIDateStringToDate(objItem.DHCPLeaseObtained)
WScript.Echo "DHCPServer: " & objItem.DHCPServer
WScript.Echo "DNSDomain: " & objItem.DNSDomain
strDNSDomainSuffixSearchOrder =
Join(objItem.DNSDomainSuffixSearchOrder, ",")
WScript.Echo "DNSDomainSuffixSearchOrder: " &
strDNSDomainSuffixSearchOrder
WScript.Echo "DNSEnabledForWINSResolution: " &
objItem.DNSEnabledForWINSResolution
WScript.Echo "DNSHostName: " & objItem.DNSHostName
strDNSServerSearchOrder = Join(objItem.DNSServerSearchOrder, ",")
WScript.Echo "DNSServerSearchOrder: " & strDNSServerSearchOrder
WScript.Echo "DomainDNSRegistrationEnabled: " &
objItem.DomainDNSRegistrationEnabled
WScript.Echo "ForwardBufferMemory: " & objItem.ForwardBufferMemory
WScript.Echo "FullDNSRegistrationEnabled: " &
objItem.FullDNSRegistrationEnabled
strGatewayCostMetric = Join(objItem.GatewayCostMetric, ",")
WScript.Echo "GatewayCostMetric: " & strGatewayCostMetric
WScript.Echo "IGMPLevel: " & objItem.IGMPLevel
WScript.Echo "Index: " & objItem.Index
strIPAddress = Join(objItem.IPAddress, ",")
WScript.Echo "IPAddress: " & strIPAddress
WScript.Echo "IPConnectionMetric: " & objItem.IPConnectionMetric
WScript.Echo "IPEnabled: " & objItem.IPEnabled
WScript.Echo "IPFilterSecurityEnabled: " &
objItem.IPFilterSecurityEnabled
WScript.Echo "IPPortSecurityEnabled: " & objItem.IPPortSecurityEnabled
strIPSecPermitIPProtocols = Join(objItem.IPSecPermitIPProtocols, ",")
WScript.Echo "IPSecPermitIPProtocols: " & strIPSecPermitIPProtocols
strIPSecPermitTCPPorts = Join(objItem.IPSecPermitTCPPorts, ",")
WScript.Echo "IPSecPermitTCPPorts: " & strIPSecPermitTCPPorts
strIPSecPermitUDPPorts = Join(objItem.IPSecPermitUDPPorts, ",")
WScript.Echo "IPSecPermitUDPPorts: " & strIPSecPermitUDPPorts
strIPSubnet = Join(objItem.IPSubnet, ",")
WScript.Echo "IPSubnet: " & strIPSubnet
WScript.Echo "IPUseZeroBroadcast: " & objItem.IPUseZeroBroadcast
WScript.Echo "IPXAddress: " & objItem.IPXAddress
WScript.Echo "IPXEnabled: " & objItem.IPXEnabled
strIPXFrameType = Join(objItem.IPXFrameType, ",")
WScript.Echo "IPXFrameType: " & strIPXFrameType
WScript.Echo "IPXMediaType: " & objItem.IPXMediaType
strIPXNetworkNumber = Join(objItem.IPXNetworkNumber, ",")
WScript.Echo "IPXNetworkNumber: " & strIPXNetworkNumber
WScript.Echo "IPXVirtualNetNumber: " & objItem.IPXVirtualNetNumber
WScript.Echo "KeepAliveInterval: " & objItem.KeepAliveInterval
WScript.Echo "KeepAliveTime: " & objItem.KeepAliveTime
WScript.Echo "MACAddress: " & objItem.MACAddress
WScript.Echo "MTU: " & objItem.MTU
WScript.Echo "NumForwardPackets: " & objItem.NumForwardPackets
WScript.Echo "PMTUBHDetectEnabled: " & objItem.PMTUBHDetectEnabled
WScript.Echo "PMTUDiscoveryEnabled: " & objItem.PMTUDiscoveryEnabled
WScript.Echo "ServiceName: " & objItem.ServiceName
WScript.Echo "SettingID: " & objItem.SettingID
WScript.Echo "TcpipNetbiosOptions: " & objItem.TcpipNetbiosOptions
WScript.Echo "TcpMaxConnectRetransmissions: " &
objItem.TcpMaxConnectRetransmissions
WScript.Echo "TcpMaxDataRetransmissions: " &
objItem.TcpMaxDataRetransmissions
WScript.Echo "TcpNumConnections: " & objItem.TcpNumConnections
WScript.Echo "TcpUseRFC1122UrgentPointer: " &
objItem.TcpUseRFC1122UrgentPointer
WScript.Echo "TcpWindowSize: " & objItem.TcpWindowSize
WScript.Echo "WINSEnableLMHostsLookup: " &
objItem.WINSEnableLMHostsLookup
WScript.Echo "WINSHostLookupFile: " & objItem.WINSHostLookupFile
WScript.Echo "WINSPrimaryServer: " & objItem.WINSPrimaryServer
WScript.Echo "WINSScopeID: " & objItem.WINSScopeID
WScript.Echo "WINSSecondaryServer: " & objItem.WINSSecondaryServer
WScript.Echo
Next
Next

Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" &
Mid(dtmDate,13, 2))
End Function

'### fin de script ###

Tu remarquera donc particulièrement la ligne
"trIPAddress = Join(objItem.IPAddress, ",")
WScript.Echo "IPAddress: " & strIPAddress"

Qui devrait bien t'aider :)

Cordialement,
--
Jonathan BISMUTH
MVP Windows Server - Directory Services
MCSE 2000/ADSI-AutoIT Scripter
Transcript (ID: 691839, code: MCSE2000)
www.portail-mcse.net

"Info"
Bonjour,

Je recherche le moyen de faire un filtre WMI pour une GPO en récupérant
l'adresse IP des ordinateurs.
Je ne trouve pas la classe ou la méthode pour récupérer l'adresse IP.
Est-ce que quelqu'un pourrait m'aider ?

En vous remerciant par avance,


Publicité
Poster une réponse
Anonyme