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