use strict; use warnings; use Win32::OLE qw(in); $|++; my $machine = '.'; # Replace this to query a remote machine '.' picks the localhost my $object = Win32::OLE->GetObject('winmgmts:{impersonationLevel=impersonate}!//' . $machine ); foreach my $nic ( in $object->InstancesOf('Win32_NetworkAdapterConfiguration') ) { next unless $nic->{IPEnabled}; next if $nic->{Caption} =~ /VMware Virtual/; # Mac Address print $nic->{MACAddress}, "\n"; # IP Address(es), there can be more than one print join( ' ', @{ $nic->{IPAddress} } ), "\n"; # Default gateway print join(' ', @{ $nic->{DefaultIPGateway} }), "\n" if $nic->{DefaultIPGateway}; # DHCP Server ( if applicable ) print $nic->{DHCPServer}, "\n" if $nic->{DHCPEnabled}; # DNS Servers ( if applicable ) print join(' ', @{ $nic->{DNSServerSearchOrder} } ), "\n" if $nic->{DNSServerSearchOrder}; } exit 0;