|
Folks-
I just came up with this script, that I'm going to use
to get the MAC address on a W32 machine. The reason
is that ipconfig does not show a wireless interface, when
the mechanical switch is turned off. This script does.
-Craig
use strict;
use warnings;
use English;
use Data::Dumper;
use Win32;
use Win32::OLE qw (in);
# Generate OLE class name for current computer...
my $Class = "WinMgmts://" . Win32::NodeName();
# Create WMI Object...
my $Wmi = Win32::OLE->GetObject ($Class) ||
die "Can't get OLE object for $Class";
# Query for network adapters...
my $NetInterfaces =
$Wmi->ExecQuery("SELECT * FROM Win32_NetworkAdapter");
if (scalar(in($NetInterfaces)) lt "1") {
die "\a\n\tCheck the computer and class name.\n",
"\tNo information was found on specified class!\n";
}
my @NetInfo;
foreach my $i (in($NetInterfaces)) {
my %node;
foreach my $prop (in $i->{Properties_}) {
if($prop->{Value}) {
$node{$prop->{Name}} = $prop->{Value};
}
}
$NetInfo[$node{Index}] = \%node;
}
print Dumper(\@NetInfo);
|