#!perl #Change These Variables (Leave all variables BLANK if connecting to locahost)# $server=""; $remote_user=""; $remote_pass=""; use Win32::OLE qw(in with); use Win32::OLE::Enum; Win32::OLE->Option(Warn => 0); ##WMI Connect## $WMI = Win32::OLE->new('WbemScripting.SWbemLocator'); if(!$WMI){ print Win32::OLE->LastError(); exit; } $Services = $WMI->ConnectServer($server, "root/cimv2", $remote_user, $remote_pass); if(!$Services){ $err_tmp_raw=Win32::OLE->LastError(); $err_tmp=Win32::OLE->LastError(); $err_tmp=~s/\'/\\'/g; $err_tmp=~s/\"/\\"/g; $err_tmp='Access Denied' if($err_tmp=~m/denied/i); $err_tmp='WMI Not Installed' if($err_tmp=~m/class not registered/i); $err_tmp='RPC Server Unavailable' if($err_tmp=~m/rpc server is unavailable/i); print "$err_tmp\n"; print Win32::OLE->LastError(); exit; } my $Processor_set = $Services->InstancesOf("Win32_Processor"); foreach my $object (Win32::OLE::Enum->All($Processor_set)){ print "CPU: $object->{'caption'}\n"; print "CPU Utilization: $object->{'LoadPercentage'}\n"; }