by Dana Daugherty
Here are 3 methods you can use to monitor
the status your client upgrades.
Using queries and Windows Script Host, Dana Daugherty gives you 3 ways to track the SMS 2.0 SP2 Upgrade.
*Note: This information came from Cliff Hobb’s SMS
FAQ and the SMS 2.0 Services Packs Deployment White Paper.
Create a collection or query based on this WQL code:
select
Name, ClientVersion from SMS_R_System where ClientVersion >=
“2.00.1493” order by Name
Client Component Version
Checking
SMS 2.0 SP1 and SMS 2.0 SP2 each has a support
file called the Client Component MOF that you can use to enhance
client upgrade monitoring. Support files are available, by default,
in your Program FilesSMS 2.0 Supportability Files directory after
you run the Support.exe program found in the Support directory of
your service pack source.
The Client Component MOF file enables SMS
hardware inventory to report data on each client component. For each
component, the current and pending version is reported along with
the current state, such as Not Available, Installed,
or Reboot Required. Note that this is the same information
that is reported on the client in the Systems
Management Properties dialog box, (click the Systems
Management icon in Control Panel). SMS gathers this data during
hardware inventory and it can be displayed in the Resource Explorer
under the SMS Client State group class.
You must add the Client Component MOF File
(SMSClient.mof) to the SMS_def.mof file located on the SMS site
server in the SMSInboxesClifiles.srcHinv directory. To do this,
copy the contents of the SMSClient.mof file and append the contents
to the end of the SMS_def.mof file. You can also perform this task
by typing a command, such as the following, at a command line:
copy /a SMS_def.mof + SMSClient.mof
SMS_Def_New.mof
After appending SMSClient.mof to SMS_def.mof, use
the MOF Compiler tool (MofComp.exe) to verify that the resulting MOF
file compiles. The MOF Compiler tool is installed automatically with
SMS 2.0. The MOF Compiler tool is also part of the WMI SDK, so for
more information about compiling MOF files, see the WMI SDK
documentation. After compiling the new MOF file, rename the original
SMS_def.mof to SMS_def.old and rename new MOF file (SMS_Def_New.mof)
to SMS_def.mof. SMS will automatically replicate the changes to all
clients.
The class that the client component version data
is available from is SMS_G_System_SMS_CLIENT in the
rootSMSsite_sitecode> namespace.
The useful properties are:
–
ResourceID – a numeric value that can be used to
relate the instances to instances for the same resource in other SMS
classes
–
Component – “Remote Control”, for example
–
Version – 2.00.1417.2000 (for a particular beta
version of SMS 2.0 SP2. Your version will vary.)
–
State – “Installed”
You should successfully apply the service pack to
a test computer and determine the actual version number from the
Systems Management icon in Control Panel.
Note that the registry entries collected by this
technique could be checked directly using Regedit.exe or a similar
program.
Service Pack Deployment
Reporting
As discussed in the section “Preparing to Monitor
the Deployment”, reports indicating the percentage of computers that
are successfully upgraded at each site would be very useful for
monitoring the service pack deployment. Producing such reports is
not easy using many traditional SMS reporting tools, for several
reasons:
–
WMI Query Language (WQL) does not have a Count()
function
–
Two queries are required to calculate percentages ?
one to give a count of all clients (or components, etc.) at each
site and another to give a count of all clients (etc.) that have
been upgraded at the sites.
–
Some SMS classes require parameters to be specified
before they return results. SMS_ComponentSummarizer is an example of
this kind of class.
Some reporting tools are very powerful and can be
used despite these limitations. However, a simple alternative is to
use Windows Script Host (WSH) scripts. WSH scripts are very flexible
and powerful, but they are also easy to work with.
The following WSH script can be used to produce a
report of service pack deployment success for your sites and their
clients:
Microsoft
provides script, macro and other code examples for illustration
only, without warranty either expressed or implied, including but
not limited to the implied warranties of merchantability and/or
fitness for a particular purpose. These samples are provided ‘as is’
and Microsoft does not guarantee that the following script, macro or
code can be used in all situations. Microsoft does not support
modifications of the script, macro or code to suit customer
requirements for a particular purpose. While Microsoft support
engineers can help explain the functionality of a particular script
function, macro or code example, they will not modify these examples
to provide added functionality, nor will they help you construct
scripts, macros or code to meet your specific needs. If you have
limited programming experience, you may want to consult one of the
Microsoft Solution Providers. Solution Providers offer a wide range
of fee-based services, including creating custom scripts. For more
information about Microsoft Solution Providers, call Microsoft
Customer Information Service at (800) 426-9400.
Expected_Version=”1493″ ‘replace with the build number
of the service pack
Dim loc
Set loc = CreateObject(“WbemScripting.SWbemLocator”)
Dim WbemServices
Set WbemServices = loc.ConnectServer( , “rootSMSsite_CEN”)
‘change site code
Dim Site
Dim Sites
Dim Machines
Set Sites = WbemServices.ExecQuery(“Select * From
SMS_Site”)
For Each Site In Sites
Potential=0
Set
Machines = WbemServices.ExecQuery(“Select * From SMS_R_System WHERE
SMS_R_System.SMSAssignedSites[1]='” + Site.SiteCode + “‘”)
On
Error Resume Next ‘we don’t mind if none are upgraded
Potential=Machines.Count
On
Error Goto 0
NumUpgraded=0
Set
Machines = WbemServices.ExecQuery(“Select * From SMS_R_System WHERE
SMS_R_System.SMSAssignedSites[1]='” + Site.SiteCode + “‘ AND
SMS_R_System.ClientVersion LIKE ‘%”+Expected_Version+”%'”)
On
Error Resume Next ‘we don’t mind if none are upgraded
NumUpgraded=Machines.Count
On
Error Goto 0
SiteInfo = Site.SiteCode +” (“+ Site.SiteName +”)”
If
Instr(1, Site.Version, Expected_Version)0 Then
SiteInfo = SiteInfo + ” –
Site Upgraded”
Wscript.Echo SiteInfo + Space(50-LEN(SiteInfo)),
INT(NumUpgraded/Potential*100), “% of its”, Potential, “clients are
upgraded”
Else
Wscript.Echo SiteInfo + ” – Site Not Upgraded”
End
If
Next
The output of this script will look like:
CEN (New York) – Site Not Upgraded
NOT (Nottingham) – Site Upgraded
12 % of its 8 clients are upgraded
PRI (Prioria) – Site Not Upgraded
This script must be changed to use the site code
for your central site (instead of “CEN”), and you must change the
first line to reflect the build number of the service pack you are
applying. You can determine the build number by checking the version
of any clients or servers that you have upgraded in your test
environment. As written, the script must be run on the central site
server, but you can specify the server, a username, and password to
the ConnectServer method if you want to run this script remotely.
You should refer to the SMS SDK for details on such issues.
If you want to verify that the SMS site
components have been successfully upgraded at all sites, you can use
the following script:
Dim loc
Set loc = CreateObject(“WbemScripting.SWbemLocator”)
Dim WbemServices
Set WbemServices = loc.ConnectServer( ,
“rootSMSsite_CEN”)
Dim Site
Dim Sites
Dim Component
Dim Components
Set Sites = WbemServices.ExecQuery(“Select * From
SMS_Site”)
For Each Site In Sites
Set
Components = WbemServices.ExecQuery(“Select * From
SMS_ComponentSummarizer WHERE SiteCode='” + Site.SiteCode + “‘ AND
TallyInterval=’000A470000284400’ AND Status1”)
On
Error Resume Next ‘we don’t mind if there are no messages
For
Each Component In Components
If Err.Number=0 Then
Wscript.Echo Component.SiteCode + “: ” +
Component.ComponentName
NumComponents=NumComponents+1
End If
Next
On
Error Goto 0
Next
If NumComponents=0 Then Wscript.Echo “All components were
upgraded successfully.”
If any components are in an “Installing” or other
unusual state, they are listed with the site code. You can then go
to the site and investigate further.
Again, the site code (“CEN”), must be changed to
match your site, and the script must be run on the site server
itself. The TallyInterval limits the Component Summarizer to check
since the first of the current month. Alternate tally intervals can
be specified using values listed in the SMS SDK, under the “Using
Summarizers” topic.
The following sample script will report the
version of SMS at all sites, in the order of your hierarchy. It does
not include details about the client deployment.
Sub Level( parent, depth, extended_Description )
Dim Site
Dim Sites
Set Sites = WbemServices.ExecQuery(“Select * From SMS_Site
Where ReportingSiteCode='”+parent+”‘”)
For Each Site In Sites
zBuild=Site.BuildNumber
If Site.BuildNumber Then zBuild=”SMS 1.0″
If Site.BuildNumber=692
Then zBuild=”SMS 1.1″
If Site.BuildNumber=786
Then zBuild=”SMS 1.2″
If Site.BuildNumber=1239 Then zBuild=”SMS 2.0 (no SP)”
If Site.BuildNumber>1239 AND Site.BuildNumber
If Site.BuildNumber=1380 Then zBuild=”SMS 2.0 SP1″
If Site.BuildNumber>1380 AND Site.BuildNumber
If Site.BuildNumber=1493 Then zBuild=”SMS 2.0 SP2″
If Site.BuildNumber>1493 Then zBuild=”SMS 2.0 post-SP2 (”
& Site.BuildNumber & “)”
Descr=Site.SiteName + ” (“+Site.SiteCode+”) “
Descr=SPACE( depth*3 ) + Descr
Descr=Left( Descr, 35)
Descr=Descr + SPACE(36-LEN(Descr))
Wscript.Echo Descr & zBuild
extended_Description=extended_Description + Chr(13) + Descr
& zBuild
Level Site.SiteCode, depth+1, extended_Description
Next
End Sub
Dim loc
Set loc = CreateObject(“WbemScripting.SWbemLocator”)
Dim WbemServices
Set WbemServices = loc.ConnectServer( ,
“rootSMSsite_CEN”)
‘start with the cental site
Dim xDescr
xDescr=””
Level “”, 0, xDescr
‘pause so the command line output can be seen, or to cut and
paste it to a text file
MsgBox “”,, “SMS Site Versions”
‘or, in case you prefer a window output (but’s it’s a proportionate
font)
‘MsgBox xDescr,, “SMS Site Versions”
For more information about WSH, see
http://msdn.microsoft.com/scripting/. WSH is included with
Microsoft Windows 2000 and Internet Explorer 5. To use WSH on computers running
Windows NT 4.0 without IE 5, you must download WSH from the WSH Web site.