Any perl code for AD object date stamp
Hello, Does anyone have any sample perl code to connect and scan Microsoft Active Directory and dump when objects (users, computers) were added to Active Directory (ie. Object birth dates)? Thanks, Frank ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Check for local firewall
Is there a way to check whether a local firewall is enabled? Also is there a way to enable a firewall if it is not? The Microsoft security center (firewall,virus,updates) seems to have a way to check for whether the Microsoft or other vendor firewall is enabled. Thanks, Frank ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: network inventory
MACs will provide manufacturers (look for OUI tables using Google), though they will not provide model information. Keep in mind network devices exist at later 2 that are not manageable and may not have a MAC address. If you can identify from say a switch and you see multiple MAC addresses on a particular port it may indicate that there is another switch including a non manageable hub on that port. I suggest reading up on SNMP as another post suggested, MIB2, and how to determine the private (if any OID trees exist). Cheers, Frank Pikelner On 5/26/05 1:38 PM, Chris [EMAIL PROTECTED] wrote: Is there anything out there that would allow to identify a network device as a (router, switch, firewall etc)? If you can obtain the device's MAC address, you should be able to determine it's manufacturer and possibly model. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Perl WMI locks profile when executed unattended
I have a script that produces status information for server queues. When I execute the script from the server command line I obtain the desired results. When the script is executed unattended by the local account of servers (using AutoExNT from Win2k resource kit) service the local profile of the account used to executes the script gets locked (unable to delete the profile). This would indicate that something is still open and the profile cannot be closed properly by the system. I would appreciate if someone could have a look and let me know if there is something obvious I'm missing. The code in question is should only be the of the *** SUB HW_INV *** # *** MODULES *** use DBI; use DBD::mysql; use Socket; use Sys::Hostname; use Win32::OLE qw(in with); # *** VARIABLES *** my $count = 0; my $host= hostname(); my $db = 'DBI:mysql:testDB:test.domain.com; my $username = 'user'; my $pass = 'password'; # *** CONSTANTS *** my %detectedErrorState = ( 0 = [ Unknown ], 1 = [ Other ], 2 = [ No error ], 3 = [ Low paper ], 4 = [ No paper ], 5 = [ Low toner ], 6 = [ No toner ], 7 = [ Door open ], 8 = [ Jammed ], 9 = [ Offline ], 10 = [ Service requested ], 11 = [ Output bin full ]); my %Status = ( 1 = [ Other ], 2 = [ Unknown ], 3 = [ Idle ], 4 = [ Printing ], 5 = [ Warmup ], 6 = [ Stopped printing ], 7 = [ Offline ]); # *** MAIN *** @ctime = localtime(time); $day = $ctime[3]; $month = $ctime[4] + 1; $year = $ctime[5] + 1900; $newdate = sprintf(%s-%02s-%02s,$year,$month,$day); #printf($newdate\n); hw_inv; #print ($printer_server: ($count) Printer Alerts. Done.\n); #exit(0); exit; # *** END MAIN *** # *** SUB HW_INV *** sub hw_inv { # Gather Printer Status my $WMI = Win32::OLE-new('WbemScripting.SWbemLocator') || die Cannot access WMI on local server: , Win32::OLE-LastError; my $Services = $WMI-ConnectServer($host) || die Cannot access WMI on remote machine: , Win32::OLE-LastError; # Gather Computer System Information my $printer_set = $Services-InstancesOf(Win32_Printer); my $dbh = DBI-connect($db, $username, $pass) || die $DBI::errstr,\n; foreach my $printer (in($printer_set)) { my $printer_name = $printer-{'Caption'}; my $printer_desc = $printer-{'Description'}; my $printer_error= $printer-{'DetectedErrorState'}; my $printer_driver = $printer-{'DriverName'}; my $printer_jobs = $printer-{'JobCountSinceLastReset'}; my $printer_location = $printer-{'Location'}; my $printer_state= $printer-{'PrinterState'}; my $printer_status = $printer-{'PrinterStatus'}; my $printer_stat = $printer-{'Status'}; my $printer_server = $printer-{'SystemName'}; if ($printer_error != 0) { $count++; my $sql = $dbh-prepare(INSERT INTO SUPPORTPRINTER (Printer, Jobs, Message, Status, Model, Executed) VALUES ('$printer_name',$printer_jobs,'$detectedErrorState{$printer_error}[0]','$St atus{$printer_status}[0]','$printer_driver','$newdate');); $sql-execute(); } if (($printer_error == 0) ($printer_status == 1)) { $count++; my $sql = $dbh-prepare(INSERT INTO SUPPORTPRINTER (Printer, Jobs, Message, Status, Model, Executed) VALUES ('$printer_name',$printer_jobs,'$detectedErrorState{$printer_error}[0]','$St atus{$printer_status}[0]','$printer_driver','$newdate');); $sql-execute(); } } $dbh-disconnect(); } # *** END HW_INV *** Frank Pikelner ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
sending email in HTML format
Hello, I need to write a short Perl program that will send email containing an HTML table with data. My script succeeds sending on the the email, but the HTML does not get interpreted by the client as HTML and appears as HTML tags with the data. My guess is it is something with the HTML that needs to tell the client to interpret the HTML and not display as text. Here is the code I use: # *** MODULES *** use Socket; use Sys::Hostname; use Net::SMTP; use Win32::OLE qw(in with); print ($host); # *** CONSTANTS *** my %detectedErrorState = ( 0 = [ Unknown ], 1 = [ Other ], 2 = [ No error ], 3 = [ Low paper ], 4 = [ No paper ], 5 = [ Low toner ], 6 = [ No toner ], 7 = [ Door open ], 8 = [ Jammed ], 9 = [ Offline ], 10 = [ Service requested ], 11 = [ Output bin full ]); my %Status = ( 1 = [ Other ], 2 = [ Unknown ], 3 = [ Idle ], 4 = [ Printing ], 5 = [ Warmup ], 6 = [ Stopped printing ], 7 = [ Offline ]); # *** VARIABLES *** my $count = 0; my $smtp_host = 'mail.--.com'; my $from = 'me.--.com'; my @to = ('fun..com','test..com'); my $subject = ''; #my $header = Please review the following printing items:\n\n; my $header = ; my $message = ; my $host = hostname(); # *** MAIN *** $header = \n\n\nhtmlheadh1PRINTER TEST/h1/headbodytable; $message = $header . $message; $message = $message . trtdPRINTER/tdtdJOBS/tdtdMESSAGE/tdtdSTATUS/tdtdMODEL/td/tr; hw_inv; $message = $message . /table/body/html\n\n\n; if ($count 0) { SendEmail; } else { print ($printer_server: ($count) Printer Alerts. Done.\n); } exit(0); # *** END MAIN *** # *** SUB SENDMAIL *** sub SendEmail { my $smtp; if ( $smtp = new Net::SMTP( $smtp_host ) ) { $smtp - mail( $from ); $smtp - to( @to ); $smtp - data(); $smtp - datasend(To: $to\n); $smtp - datasend(Subject: $subject\n); $smtp - datasend(\n); $smtp - datasend($message\n); $smtp - datasend(); $smtp - quit(); print(Success: Sent message to @to\n); print($subject\n); } else { print(Failed: send message to @to\n); } } # *** END SENDMAIL *** # *** SUB HW_INV *** sub hw_inv { # Gather Printer Status $WMI = Win32::OLE-new('WbemScripting.SWbemLocator') || die Cannot access WMI on local server: , Win32::OLE-LastError; $Services = $WMI-ConnectServer($host) || die Cannot access WMI on remote machine: , Win32::OLE-LastError; # Gather Computer System Information $printer_set = $Services-InstancesOf(Win32_Printer); foreach $printer (in($printer_set)) { $printer_name = $printer-{'Caption'}; $printer_desc = $printer-{'Description'}; $printer_error = $printer-{'DetectedErrorState'}; $printer_driver = $printer-{'DriverName'}; $printer_jobs = $printer-{'JobCountSinceLastReset'}; $printer_location = $printer-{'Location'}; $printer_state = $printer-{'PrinterState'}; $printer_status = $printer-{'PrinterStatus'}; $printer_stat = $printer-{'Status'}; $printer_server = $printer-{'SystemName'}; if ($printer_error != 0) { $count++; #$message = $message . $printer_name\t$printer_jobs\t\t$detectedErrorState{$printer_error}[0]\t\t$Status{$printer_status}[0]\t\t\t$printer_driver\n; $message = $message . trtd$printer_name/tdtd$printer_jobs/tdtd$detectedErrorState{$printer_error}[0]/tdtd$Status{$printer_status}[0]/tdtd$printer_driver/td/tr; } if (($printer_error == 0) ($printer_status == 1)) { $count++; #$message = $message . $printer_name\t$printer_jobs\t\t$detectedErrorState{$printer_error}[0]\t\t$Status{$printer_status}[0]\t\t\t$printer_driver\n; $message = $message . trtd$printer_name/tdtd$printer_jobs/tdtd$detectedErrorState{$printer_error}[0]/tdtd$Status{$printer_status}[0]/tdtd$printer_driver/td/tr; } } $subject = $printer_server: ($count) Printer Alerts; } # *** END HW_INV *** Frank Pikelner [EMAIL PROTECTED]