/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" PowerShell, Has my Dell a dangerous battery ? "," PowerShell Adding -verbose switch to functions "," PowerShell and Active Directory Part 9 (nested gro... "," Powershell and hey Scripting guy ! "," PowerShell Orphan share remover Tool (Update) "," PowerShell and Active Directory Part 8 (ACL's) "," Signing PowerShell Scripts "," PowerShell and Active Directory Part 7 "," PowerShell and Active Directory Part 6 "," Windows PowerShell Video: Next Generation Command ... "," ")

Thursday, August 31, 2006

 


Powershell, Has my Dell a dangerous battery Part 2 ?



Yesterday after I posted  PowerShell, Has my Dell a dangerous battery ? , I did meet James Thruher

on IRC (irc.freenode.net channel  #Powershell ), and while discussing the script he came to the idea to  get the serials direct from the Dell site.

b.t.w. if you want to join us on IRC pleasy check it out, on that IRC channel you can also meet amongs others :

Some other regulars on : irc.freenode.net channel  #Powershell are :

DbmwS Don't Bother me with Spam (aka D2D, Dance to die ) from  monadblog  and http://del.icio.us/powershell and very active on the PowerShell Newsgroup : Windows Powershell

Karl Prosser, the guy behind PowerShell Analyzer : Karl Prosser - Klumsy Geek (note that he has a public Alpha release of PowerShell Analyzer (a great PowerShell editor) out now that you can download from his blog)

Arild : from AnkhSVN and also PowerShell fan see his Blog  (see also (PowerShell, AnkhSVN and Subversion) on Scott Hanselman's blog)

 

So, as I did see the new Item on Jim's blog this morning I did think he posted it  as my last remark was :

<jtruher> it's still doesn't seem to be quite right - it seems to miss a couple of numbers
* mow001 needs some sleep, see it on your blog ;-)

, but better yet, he posted an other real cool script Background "jobs" and PowerShell.

but as I did see also some differences between his (scraped from the Dell site) and my list, see the compare below,  and I think it is a very cool addition I will post it here also.

MSH>compare-object ($AffectedSerials | sort) ($dell | sort)

InputObject SideIndicator
----------- -------------
1K055 =>
5P474 =>
J1524 =>
OR331 =>
59474 <=

Jim did post the solution as a comment 2 comments on last post, but I will post that example here also . and try to keep the &amp;nbsp

 

<jtruher> blast - the HTML renderer changed my &amp;nbsp; to a real space
<mow001> I will add it to my new post thanks

I will post a complete script again to check this I made 2 options, use the current list ( I made a fresh one with the latest list with the trick below for if yyou have no internet), or it can download it from the Dell site.

 

MSH>[string]::join("','",$AffectedSerials)
3K590','59474','6P922','C2603','C5339','C5340','C5446','C6269','C6270','D2961','D5555','D6024','D6025
','F2100','F5132','GD785','H3191','JD616','JD617','KD494','M3006','RD857','TD349','U5867','U5882','W5
915','X5308','X5329','X5332','X5333','X5875','X5877','Y1333','Y4500','Y5466

# changed in notepad to :

 

$affectedSerials = '3K590','59474','6P922','C2603',
'C5339','C5340','C5446','C6269','C6270','D2961','D5555',
'D6024','D6025','F2100','F5132','GD785','H3191','JD616',
'JD617','KD494','M3006','RD857','TD349','U5867','U5882',
'W5915','X5308','X5329','X5332','X5333','X5875','X5877',
'Y1333','Y4500','Y5466'

 

So now it works like this : 

 

MSH>.\CheckBattery.msh
retrieved affected serials 1K055 C5446 F2100 KD494 W5915 Y1333 3K590 C6269 F5132 OR331 X5308 Y4500 5
P474 C6270 GD785 M3006 X5329 Y5466 6P922 D2961 H3191 RD857 X5332 C2603 D5555 J1524 TD349 X5333 C5339
D6024 JD616 U5867 X5875 C5340 D6025 JD617 U5882 X5877
Battery Model : DELL 4M0105
MSH>.\CheckBattery.msh -internal
Battery Model : DELL 4M0105

 

and the script looks like this :

 

# CheckBattery.ps1
#
# Check Dell Battery for Fire Hazard
# Thanks to James Thruher for the Web Part

# /\/\o\/\/ 2006
# http://mow001.blogspot.com

Param ($computer = ".",
        [switch]$internalList)

if ($internalList.IsPresent) { 
  $script:affectedSerials = '3K590','59474','6P922','C2603',
  'C5339','C5340','C5446','C6269','C6270','D2961','D5555',
  'D6024','D6025','F2100','F5132','GD785','H3191','JD616',
  'JD617','KD494','M3006','RD857','TD349','U5867','U5882',
  'W5915','X5308','X5329','X5332','X5333','X5875','X5877',
  'Y1333','Y4500','Y5466'

Else { 
  $wc = new net.webclient
  $bat = $wc.downloadstring("https://www.dellbatteryprogram.com/")
  $r = [regex]"&nbsp;([A-Z0-9][A-Z0-9][0-9][0-9][0-9])"

  $matches = $r.matches($bat)
  $script:AffectedSerials = $matches | foreach { $_.groups[1].captures[0].value }
  "retrieved  affected serials $($script:AffectedSerials)"


get-WmiObject win32_battery | Foreach { 
  $Name = $_.name 
  write-host "Battery Model : $name"
  $script:AffectedSerials | Where {$name -match $_} | Foreach { 
      Write-Warning "Affected : Battery $Name matches : *$_*" 
  } 
}

Note as in the other post (I forgot to mention it but )you can give also a computername to connect to a remote system.

And this time I made it as a script that you can run .

Enjoy,

Greetings, /\/\o\/\/
Tags : Monad msh PowerShell


Comments: Post a Comment



<< Home

Archives

October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Google
 
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?