Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Grouping by patches using powergadget

Reply
 
Old 12-28-2007   #1 (permalink)
IT Staff


 
 

Grouping by patches using powergadget

foreach ($computer in $computernames)
{
foreach ($kb in $patches)
{
$checkkb = Get-WmiObject Win32_QuickFixEngineering -computer $computer |
where-object {$_.hotfixid -eq $kb}

if ($checkkb)
{write-host $kb "(found)" "`r"}
else
{write-host -f red $kb "(Not found)" "`r"}
}
===================================================================================
the code works fine. i want to group by patches and count the machine that
has the patch, and count computers that has no patch. (for each patch in the
loop). How shld i approach the problem ?

Once i group them , i will pipe out to powergadget





My System SpecsSystem Spec
Old 12-30-2007   #2 (permalink)
IT Staff


 
 

Re: Grouping by patches using powergadget

$computernames = get-content $pclist
$patches = get-content $kblist
foreach ($computer in $computernames)
{
$strQuery = "select * from win32_pingstatus where address = '" + $computer
+ "'"
$wmi = Get-WmiObject -query $strQuery

write-host -f green "Computer Name : " $computer.toupper() "`r"
if ($wmi.statuscode -eq 0)
{
foreach ($kb in $patches)
{
$checkkb = Get-WmiObject Win32_QuickFixEngineering -computer $computer |
where-object {$_.hotfixid -eq $kb}

if ($checkkb)
{
write-host $kb "(found)" "`r"
}
else
{
write-host $kb "(Not found)" "`r"
}
}
}
else
{write-host -f "Ping failed." "`r"}
write-host "`r"
}
=======================================================

i would like grouping to be :

kb942763 = 5 computers found
kb942763 = 1 computers not found

kb928365 = 2 computers found
kb928365 = 4 computers not found

















"Keith Hill [MVP]" <r_keith_hill@xxxxxx_spam_I> wrote in message
news:B97FCFB9-51CF-401C-93C7-0AFA18DB6D6F@xxxxxx
Quote:

> "IT Staff" <jkklim@xxxxxx> wrote in message
> news:uB5S1ZTSIHA.2376@xxxxxx
Quote:

>> foreach ($computer in $computernames)
>> {
>> foreach ($kb in $patches)
>> {
>> $checkkb = Get-WmiObject Win32_QuickFixEngineering -computer $computer |
>> where-object {$_.hotfixid -eq $kb}
>>
>> if ($checkkb)
>> {write-host $kb "(found)" "`r"}
>> else
>> {write-host -f red $kb "(Not found)" "`r"}
>> }
>> ===================================================================================
>> the code works fine. i want to group by patches and count the machine
>> that has the patch, and count computers that has no patch. (for each
>> patch in the loop). How shld i approach the problem ?
>>
>> Once i group them , i will pipe out to powergadget
>>
>
> You could try something like this:
>
> 40> $computers | foreach {$computer=$_;gwmi
> Win32_QuickFixEngineering -computer $_ | select
> HotFixID,@{n='Computer';e={$
> computer}}} | group {$kbs -contains $_.HotFixID}
>
> Count Name Group
> ----- ---- -----
> 70 False {{AC76BA86-7AD7-0000-2550-7A8C40000000},
> {D93F9C7C-AB57-44C8-BAD6-1494674BCAF7}, {89...
> 2 True {KB938194, KB942624}
>
> False means not patched and true means patched.
>
> --
> Keith

My System SpecsSystem Spec
Old 01-01-2008   #3 (permalink)
IT Staff


 
 

Re: Grouping by patches using powergadget

anyone help ?


"IT Staff" <jkklim@xxxxxx> wrote in message
news:ONlDrt1SIHA.5128@xxxxxx
Quote:

> $computernames = get-content $pclist
> $patches = get-content $kblist
> foreach ($computer in $computernames)
> {
> $strQuery = "select * from win32_pingstatus where address = '" + $computer
> + "'"
> $wmi = Get-WmiObject -query $strQuery
>
> write-host -f green "Computer Name : " $computer.toupper() "`r"
> if ($wmi.statuscode -eq 0)
> {
> foreach ($kb in $patches)
> {
> $checkkb = Get-WmiObject Win32_QuickFixEngineering -computer $computer |
> where-object {$_.hotfixid -eq $kb}
>
> if ($checkkb)
> {
> write-host $kb "(found)" "`r"
> }
> else
> {
> write-host $kb "(Not found)" "`r"
> }
> }
> }
> else
> {write-host -f "Ping failed." "`r"}
> write-host "`r"
> }
> =======================================================
>
> i would like grouping to be :
>
> kb942763 = 5 computers found
> kb942763 = 1 computers not found
>
> kb928365 = 2 computers found
> kb928365 = 4 computers not found
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> "Keith Hill [MVP]" <r_keith_hill@xxxxxx_spam_I> wrote in message
> news:B97FCFB9-51CF-401C-93C7-0AFA18DB6D6F@xxxxxx
Quote:

>> "IT Staff" <jkklim@xxxxxx> wrote in message
>> news:uB5S1ZTSIHA.2376@xxxxxx
Quote:

>>> foreach ($computer in $computernames)
>>> {
>>> foreach ($kb in $patches)
>>> {
>>> $checkkb = Get-WmiObject Win32_QuickFixEngineering -computer $computer
>>> | where-object {$_.hotfixid -eq $kb}
>>>
>>> if ($checkkb)
>>> {write-host $kb "(found)" "`r"}
>>> else
>>> {write-host -f red $kb "(Not found)" "`r"}
>>> }
>>> ===================================================================================
>>> the code works fine. i want to group by patches and count the machine
>>> that has the patch, and count computers that has no patch. (for each
>>> patch in the loop). How shld i approach the problem ?
>>>
>>> Once i group them , i will pipe out to powergadget
>>>
>>
>> You could try something like this:
>>
>> 40> $computers | foreach {$computer=$_;gwmi
>> Win32_QuickFixEngineering -computer $_ | select
>> HotFixID,@{n='Computer';e={$
>> computer}}} | group {$kbs -contains $_.HotFixID}
>>
>> Count Name Group
>> ----- ---- -----
>> 70 False {{AC76BA86-7AD7-0000-2550-7A8C40000000},
>> {D93F9C7C-AB57-44C8-BAD6-1494674BCAF7}, {89...
>> 2 True {KB938194, KB942624}
>>
>> False means not patched and true means patched.
>>
>> --
>> Keith
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Powergadget version PowerShell
Powergadget : get-content of directory PowerShell
Re: powergadget : how to pass parameters PowerShell
Powergadget - Out-Line PowerShell
Task Bar Grouping not working, box is checked, 11 windows, no grouping...HELP! TIA Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46