excel barcode generator download LIST HOT FIXES INSTALLED ON A MACHINE in C#.NET

Encoder Code 3/9 in C#.NET LIST HOT FIXES INSTALLED ON A MACHINE

LIST HOT FIXES INSTALLED ON A MACHINE
Code 39 Extended Creation In Visual C#.NET
Using Barcode encoder for VS .NET Control to generate, create Code 3/9 image in Visual Studio .NET applications.
www.OnBarcode.com
Read Code 39 Full ASCII In Visual C#.NET
Using Barcode recognizer for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
The following script will list the hot fixes installed on a list of computers. If no computer names are provided, it shows the hot fix information for this computer. We can optionally specify a set of properties to return. To get a list of all hot fixes installed on the current computer displaying all properties, do
Print UPC - 13 In C#.NET
Using Barcode creation for .NET Control to generate, create GS1 - 13 image in Visual Studio .NET applications.
www.OnBarcode.com
Generate Code 128B In C#.NET
Using Barcode encoder for .NET framework Control to generate, create Code 128 Code Set A image in Visual Studio .NET applications.
www.OnBarcode.com
Get-HotFixes
Creating GTIN - 128 In C#.NET
Using Barcode drawer for .NET Control to generate, create USS-128 image in .NET applications.
www.OnBarcode.com
Painting QR Code In Visual C#.NET
Using Barcode maker for .NET framework Control to generate, create Quick Response Code image in .NET framework applications.
www.OnBarcode.com
If you only want to see certain properties:
2D Barcode Creation In C#
Using Barcode maker for VS .NET Control to generate, create Matrix 2D Barcode image in VS .NET applications.
www.OnBarcode.com
USD8 Drawer In C#
Using Barcode generator for .NET Control to generate, create Code11 image in .NET applications.
www.OnBarcode.com
Get-HotFixes -prop ServicePackInEffect,Description
Code 39 Extended Generation In Objective-C
Using Barcode maker for iPad Control to generate, create Code 3/9 image in iPad applications.
www.OnBarcode.com
Code 39 Extended Creator In Objective-C
Using Barcode generation for iPhone Control to generate, create USS Code 39 image in iPhone applications.
www.OnBarcode.com
The listing for this script is shown in listing B.3. 502 A P P E N D I X B: A D M I N E X A M P L E S
Generating Barcode In Objective-C
Using Barcode generator for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
Barcode Drawer In None
Using Barcode drawer for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
Listing B.3 Get-HotFixes.ps1 script
European Article Number 13 Reader In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Barcode Creator In Java
Using Barcode maker for Android Control to generate, create Barcode image in Android applications.
www.OnBarcode.com
param( [string[]] $ComputerNames = @(), [string[]] $Properties = @() ) $ComputerNames += @($input) if (! $ComputerNames) { $ComputerNames = "." } if ($Properties.Length -eq 0) { Get-WmiObject -Class Win32_QuickFixEngineering ` -ComputerName $ComputerNames } else { Get-WmiObject -Class Win32_QuickFixEngineering ` -ComputerName $ComputerNames | select-object $properties }
Painting ANSI/AIM Code 39 In None
Using Barcode generation for Online Control to generate, create Code-39 image in Online applications.
www.OnBarcode.com
Print Barcode In Java
Using Barcode encoder for Eclipse BIRT Control to generate, create Barcode image in BIRT reports applications.
www.OnBarcode.com
At this point, we can see that there is a pretty consistent solution for all of these examples. Once we know the WMI class for a particular feature, the pattern for getting information about that feature is basically the same. PowerShell makes it easy to use WMI on the command line to retrieve information about the system once you know the class name.
Encoding EAN 128 In Visual Studio .NET
Using Barcode generator for Visual Studio .NET Control to generate, create GS1 128 image in .NET applications.
www.OnBarcode.com
Painting QR Code JIS X 0510 In None
Using Barcode drawer for Excel Control to generate, create QR Code image in Microsoft Excel applications.
www.OnBarcode.com
FINDING MACHINES MISSING A HOT FIX
Barcode Recognizer In .NET Framework
Using Barcode Control SDK for ASP.NET Control to generate, create, read, scan barcode image in ASP.NET applications.
www.OnBarcode.com
UCC - 12 Creation In None
Using Barcode maker for Excel Control to generate, create EAN / UCC - 13 image in Excel applications.
www.OnBarcode.com
Let s build on the script we wrote in the previous example to accomplish a more specific task. We want to write a new script that will search computers for missing hot fixes. Here s what we want the output to look like
PS (1) > ./Get-MachinesMissingHotfix.ps1 computer . ` >> -hotfix KB902841,KB902842,KB902843,KB902844 >> Name ---name missing Value ----. {KB902842, KB902843, KB902844}
This result of the command shows that three of the four hot fixes aren t installed on the current machine. APPENDIX B: ADMIN EXAMPLES 503
AUTHOR S NOTE
Some of these hot fix identifiers are fictitious so we can see some failures. So don t be worried if you cannot find them in the knowledge base.
Notice that the output retains structure. Instead of emitting strings, we re going to emit hashtables so they can more easily be used in further processing such as building update packages for distribution. And of course, since we want to be able to check a list of machines, the script can either take the list on the command line or read it from input stream as shown in the next example.
PS (2) > Get-Content machines.txt|./Get-MachinesMissingHotfix.ps1 ` >> -hotfix KB902841,KB902842,KB902843,KB902844 >> Name ---name missing name missing name missing Value ----machine1 {KB902842, KB902843, KB902844} machine4 {KB902842, KB902843, KB902844} machine5 {KB902841,KB902842, KB902843, KB902844}
The file machines.txt contains a list of machine names machine1 through machine5 to check. In the output, we see that machines 2 and 3 are up to date they don t show up in the output. Machines 1 and 4 are missing three hot fixes and machine 5 is missing all four. This script is shown in listing B.4.
Listing B.4 Get-MachinesMissingHotfix.ps1 script
param( [string[]] $ComputerName = @(), [string[]] $HotFix = $(throw "you must specify a hotfix id") ) $ComputerName += @($input) if (! $ComputerName) { $ComputerName = "." }
Calculate list of computers
$myDir = split-path $MyInvocation.MyCommand.Definition $gh = join-path $myDir Get-HotFixes.ps1
Find path to Get-HotFixes
foreach ($name in $ComputerName) { $sps = & $gh $name | foreach { $_.ServicePackInEffect} $result = @{name = $name; missing = @() }
Get hot fix list for machine
foreach ($hf in $HotFix)
Initialize result table
A P P E N D I X B: A D M I N E X A M P L E S
{ if ($sps -notcontains $hf) { $result.missing += $hf } } if ($result.missing.length -gt 0) { $result } }
Add missing hot fixes
Emit result
This script takes two parameters the list of computer names to check and the list of hot fixes to check for. If no computer names are specified, the script defaults to checking the current computer. We can specify names of computers to check both on the command line and in the input stream. We ll catenate these two lists together B. We re going to require that the Get-HotFixes script be in the same directory as this script. Given that s the case, we can figure out the path to the Get-HotFixes script by getting the path C to the current script, which is available in $MyInvocation, and then use this to build up the path to the Get-Hotfixes script. (This is a generally useful technique to keep in mind when you re writing other scripts.) Once we have the path to the Get-HotFixes command, we use it to get the list of hot fixes D, but we want only the ServicePackInEffect field, so we ll use the foreach cmdlet to extract just this property. We initialize the variable $result to be a hashtable object with the current machine name and set the list of missing hot fixes to be an empty array E. Note that we may not return this object if there are no missing hot fixes. We ll check that by seeing whether the length of the missing member in that hashtable is 0. Now loop over the list of hot fixes, checking each hot fix to see whether it s in the list installed on the target machine. If the list of installed hot fixes doesn t contain the current hot fix identifier, append that identifier to the missing array F in the result hashtable. Finally, if, after checking all of the hot fixes, the missing array in the hashtable is still of length zero, this machine has all of the hot fixes installed. If the array is nonzero then emit the $result object G.
Copyright © OnBarcode.com . All rights reserved.