Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: ipv4 ipv6 IP Address via Host Name Hostname iHost2Addr Win32_NetworkAdapterConfiguration ipEnabled ipAddress
;Get ipv6 IP address via hostname ;IPv4 and IPv6 Connections to WMI ;When connecting to a WMI namespace on a remote computer, the target computer must be running the same ;IP software as the connecting computer. For example, a computer running IPv4 cannot connect to a computer ;running IPv6, even if the connection is attempted by using a computer name in the call to IWbemLocator::ConnectServer, ;SWbemLocator.ConnectServer, or by using the winmgmts moniker connection. The reverse is also true: a computer running only IPv6 ;cannot connect to a computer running only IPv4. ; ;If the target computer is running both IPv4 and IPv6, then a connection can be made from a computer running either ;IP software. A computer name or an IP address in either IPv4 or IPv6 format can be supplied in the connection to a ;WMI namespace. ; ;A computer that runs both IPv4 and IPv6 and connects to a target computer running only IPv4 or only IPv6 must ;supply an IP address in the appropriate format for the target computer IP software. ; hostname = 'Mach1' objService = GetObject(StrCat("winmgmts:!\\" , hostname , "\root\cimv2")) query = "SELECT * FROM Win32_NetworkAdapterConfiguration where ipEnabled=TRUE" colInstances = objService.ExecQuery(query) ; loop once for each instance ForEach objInstance In colInstances ;Check if Object is EMPTY type = ObjectTypeGet(objInstance) If type=="EMPTY" Then Continue ; obtain properties propDescription = objInstance.Description ;Array of all of the IP addresses associated with the current network adapter. Starting with Windows Vista, this property can contain either IPv6 addresses or IPv4 addresses. For more information, see IPv6 and IPv4 Support in WMI. ;Example IPv6 address: "2010:836B:4179::836B:4179" ;Windows Server 2003, Windows XP, and Windows 2000: This property contains addresses in IPv4 format. Example: "172.16.22.0" arrIPAddress = objInstance.IPAddress For i = 0 To ArrInfo(objInstance.IPAddress, 1 )-1 Pause('arrIPAddress[':i:']', arrIPAddress[i]) Next Next ; close object handles colInstances = 0 objSecurity = 0 objService = 0 objLocator = 0 Exit
Article ID: W18473
Filename: Get ipv6 IP Address via Host Name.txt
File Created: 2012:06:11:08:36:44
Last Updated: 2012:06:11:08:36:44