72 |
rodolico |
1 |
#! perl
|
|
|
2 |
|
96 |
rodolico |
3 |
# simply exit if this is not Windows
|
|
|
4 |
BEGIN {
|
|
|
5 |
$^O eq "MSWin32" || exit;
|
|
|
6 |
}
|
|
|
7 |
|
101 |
rodolico |
8 |
our $VERSION = '0.1';
|
|
|
9 |
|
72 |
rodolico |
10 |
# https://perlgems.blogspot.com/2012/06/retrieve-windows-system-information.html
|
73 |
rodolico |
11 |
# install Win32
|
|
|
12 |
# install Win32::SystemInfo
|
|
|
13 |
# install Win32::DriveInfo
|
|
|
14 |
# install Win32::IPConfig
|
72 |
rodolico |
15 |
use Win32;
|
|
|
16 |
use Win32::SystemInfo;
|
|
|
17 |
use Win32::DriveInfo;
|
|
|
18 |
use Win32::IPConfig;
|
|
|
19 |
use strict;
|
|
|
20 |
use warnings;
|
|
|
21 |
|
|
|
22 |
print "OS Information\n";
|
|
|
23 |
my $computer=Win32::NodeName();
|
|
|
24 |
print "The computer name is $computer\n";
|
|
|
25 |
|
|
|
26 |
my $domain=Win32::DomainName();
|
|
|
27 |
print "The computer is a member of the $domain domain/workgroup\n";
|
|
|
28 |
|
|
|
29 |
my $OS=Win32::GetOSDisplayName();
|
|
|
30 |
print "The OS is $OS\n";
|
|
|
31 |
|
|
|
32 |
my $fs=Win32::FsType();
|
|
|
33 |
print "The filesytem is $fs\n";
|
|
|
34 |
|
|
|
35 |
my $user=Win32::LoginName();
|
|
|
36 |
print "The current user is $user\n";
|
|
|
37 |
|
|
|
38 |
my $admin=Win32::IsAdminUser();
|
|
|
39 |
if($admin!=0){
|
|
|
40 |
print "$user is running this script as admin\n\n\n";
|
|
|
41 |
}
|
|
|
42 |
else{
|
|
|
43 |
print "$user is not running this script as admin\n\n\n";
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
print "Processor and RAM Information\n";
|
|
|
47 |
my %processor;
|
|
|
48 |
Win32::SystemInfo::ProcessorInfo(%processor);
|
|
|
49 |
for (my $i=0;$i<$processor{NumProcessors};$i++) {
|
|
|
50 |
print "Processor$i\n";
|
|
|
51 |
print "Processor Name: " . $processor{"Processor$i"}{ProcessorName} . "\n";
|
|
|
52 |
print "Processor Info: " . $processor{"Processor$i"}{Identifier} . "\n";
|
|
|
53 |
print "Processor Speed: " . $processor{"Processor$i"}{MHZ} . "MHz\n\n";
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
my %memory;
|
|
|
57 |
Win32::SystemInfo::MemoryStatus(%memory, 'GB');
|
|
|
58 |
print "The computer has $memory{TotalPhys} GB of RAM\n\n\n";
|
|
|
59 |
|
|
|
60 |
my %dtypes=(0 => "Undertmined",
|
|
|
61 |
1 => "Does Not Exist",
|
|
|
62 |
2 => "Removable",
|
|
|
63 |
3 => "Hardrive",
|
|
|
64 |
4 => "Network",
|
|
|
65 |
5 => "CDROM",
|
|
|
66 |
6 => "RAM Disk");
|
|
|
67 |
|
|
|
68 |
print "Drive Information\n";
|
|
|
69 |
my @drives = Win32::DriveInfo::DrivesInUse();
|
|
|
70 |
foreach my $drive (@drives){
|
|
|
71 |
my $type=Win32::DriveInfo::DriveType($drive);
|
|
|
72 |
print "Drive $drive is a $dtypes{$type}\n";
|
|
|
73 |
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
print "\n\nNetwork Information";
|
|
|
77 |
my $ipconfig = Win32::IPConfig->new($computer)
|
|
|
78 |
or die "Unable to connect to $computer\n";
|
|
|
79 |
foreach my $adapter ($ipconfig->get_adapters) {
|
|
|
80 |
print "\nAdapter '", $adapter->get_name, "':\n";
|
|
|
81 |
|
|
|
82 |
print "Description=", $adapter->get_description, "\n";
|
|
|
83 |
|
|
|
84 |
print "DHCP enabled=",
|
|
|
85 |
$adapter->is_dhcp_enabled ? "Yes" : "No", "\n";
|
|
|
86 |
|
|
|
87 |
my @ipaddresses = $adapter->get_ipaddresses;
|
|
|
88 |
print "IP addresses=@ipaddresses (", scalar @ipaddresses, ")\n";
|
|
|
89 |
|
|
|
90 |
my @subnet_masks = $adapter->get_subnet_masks;
|
|
|
91 |
print "subnet masks=@subnet_masks (", scalar @subnet_masks, ")\n";
|
|
|
92 |
|
|
|
93 |
my @gateways = $adapter->get_gateways;
|
|
|
94 |
print "gateways=@gateways (", scalar @gateways, ")\n";
|
|
|
95 |
|
|
|
96 |
print "domain=", $adapter->get_domain, "\n";
|
|
|
97 |
|
|
|
98 |
my @dns = $adapter->get_dns;
|
|
|
99 |
print "dns=@dns (", scalar @dns, ")\n";
|
|
|
100 |
|
|
|
101 |
my @wins = $adapter->get_wins;
|
|
|
102 |
print "wins=@wins (", scalar @wins, ")\n";
|
|
|
103 |
}
|
73 |
rodolico |
104 |
|
|
|
105 |
<STDIN>;
|