# 5.14.02 Jonathan E. Dyer # Script forces a hardware inventory for SMS for a single box running +SMS. # Run script like this: forceinventory.pl <server name> # no backslashes are needed in the server name. # ping the box, and if ping response # Start SMS hardware inventory service (hwservvice) # Query the SMS hardware inventory service until it's stopped (it st +ops itself) # Stop the SMS client inventory service (cliservice) # Query the SMS client inventory service is until stopped # Start the SMS client inventory service service # Query the SMS client inventory service until it's started # else if no ping response # end use strict; use Win32::Service qw(GetStatus StopService StartService); #define variables my $server; my $hwservice='sms hardware inventory agent service'; my $cliservice='clisvc'; use Net::Ping; my $server=$ARGV[0]; #get the input #Stop/start the services my $p = Net::Ping->new("icmp"); if ($p->ping("$server",15)){; StartService("$server","$hwservice"); &getstatus($server,$hwservice,1); StopService("$server","$cliservice"); &getstatus($server,$cliservice,1); StartService("$server","$cliservice"); &getstatus($server,$cliservice,4); }else{ print "No ping response from $server"; } $p->close(); print "\n"; sub getstatus{ my %statusHash; my %statcodeHash = ('1' => 'stopped','2' => 'start pending','3' => + 'stop pending','4' => 'running','5' => 'continue pending','6' => 'pa +use pending','7' => 'paused'); do { GetStatus("$_[0]", "$_[1]", \%statusHash); }until ($statusHash{CurrentState}==$_[2]); print " $_[1] $statcodeHash{$statusHash{\"CurrentState\"}} on $_[0 +]"; }

In reply to Force SMS Hardware Inventory by OzzyOsbourne

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.