Rev 198 | Rev 231 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#! perl
# simply exit if this is not Windows
BEGIN {
$^O eq "MSWin32" || exit;
}
our $VERSION = '0.1';
# https://perlgems.blogspot.com/2012/06/retrieve-windows-system-information.html
# install Win32
# install Win32::SystemInfo
# install Win32::DriveInfo
# install Win32::IPConfig
use Win32;
use Win32::SystemInfo;
use Win32::DriveInfo;
use Win32::IPConfig;
use strict;
use warnings;
print "OS Information\n";
my $computer=Win32::NodeName();
print "The computer name is $computer\n";
my $domain=Win32::DomainName();
print "The computer is a member of the $domain domain/workgroup\n";
my $OS=Win32::GetOSDisplayName();
print "The OS is $OS\n";
my $fs=Win32::FsType();
print "The filesytem is $fs\n";
my $user=Win32::LoginName();
print "The current user is $user\n";
my $admin=Win32::IsAdminUser();
if($admin!=0){
print "$user is running this script as admin\n\n\n";
}
else{
print "$user is not running this script as admin\n\n\n";
}
print "Processor and RAM Information\n";
my %processor;
Win32::SystemInfo::ProcessorInfo(%processor);
for (my $i=0;$i<$processor{NumProcessors};$i++) {
print "Processor$i\n";
print "Processor Name: " . $processor{"Processor$i"}{ProcessorName} . "\n";
print "Processor Info: " . $processor{"Processor$i"}{Identifier} . "\n";
print "Processor Speed: " . $processor{"Processor$i"}{MHZ} . "MHz\n\n";
}
my %memory;
Win32::SystemInfo::MemoryStatus(%memory, 'GB');
print "The computer has $memory{TotalPhys} GB of RAM\n\n\n";
my %dtypes=(0 => "Undertmined",
1 => "Does Not Exist",
2 => "Removable",
3 => "Hardrive",
4 => "Network",
5 => "CDROM",
6 => "RAM Disk");
print "Drive Information\n";
my @drives = Win32::DriveInfo::DrivesInUse();
foreach my $drive (@drives){
my $type=Win32::DriveInfo::DriveType($drive);
print "Drive $drive is a $dtypes{$type}\n";
}
print "\n\nNetwork Information";
my $ipconfig = Win32::IPConfig->new($computer)
or die "Unable to connect to $computer\n";
foreach my $adapter ($ipconfig->get_adapters) {
print "\nAdapter '", $adapter->get_name, "':\n";
print "Description=", $adapter->get_description, "\n";
print "DHCP enabled=",
$adapter->is_dhcp_enabled ? "Yes" : "No", "\n";
my @ipaddresses = $adapter->get_ipaddresses;
print "IP addresses=@ipaddresses (", scalar @ipaddresses, ")\n";
my @subnet_masks = $adapter->get_subnet_masks;
print "subnet masks=@subnet_masks (", scalar @subnet_masks, ")\n";
my @gateways = $adapter->get_gateways;
print "gateways=@gateways (", scalar @gateways, ")\n";
print "domain=", $adapter->get_domain, "\n";
my @dns = $adapter->get_dns;
print "dns=@dns (", scalar @dns, ")\n";
my @wins = $adapter->get_wins;
print "wins=@wins (", scalar @wins, ")\n";
}
<STDIN>;