<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>System Center WebLog by Russ Slaten : SMS 2003</title><link>http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx</link><description>Tags: SMS 2003</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Running All Available Programs on an SMS 2003 Advanced Client</title><link>http://blogs.msdn.com/rslaten/archive/2007/10/12/running-all-available-programs-on-an-sms-2003-advanced-client.aspx</link><pubDate>Sat, 13 Oct 2007 00:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5429038</guid><dc:creator>rslaten</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/5429038.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=5429038</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=5429038</wfw:comment><description>&lt;P&gt;Recently a customer complained that&amp;nbsp;you can't run more than one advertised program at a time on a client, but they could in SMS 2.0. Here is an example VBScript that runs all available advertised programs on a client. &lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #696969"&gt;'rslaten 10/10/2007&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;'Example of how to run all available programs&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;'If you want to select some programs, but not all, then use C# or VB.NET to build a simple UI&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;'or accept parameters into this script to only run certain programs&lt;/SPAN&gt;

&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; UI &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;CreateObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"UIResource.UIResourceMgr"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; ads &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; UI&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;GetAvailableApplications
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;each&lt;/SPAN&gt; o in ads
    WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"DEBUG: Program = "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; o&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Name&lt;/SPAN&gt;
    lastRunTime &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; o&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;LastRunTime
    bIsMandatoryProgramPending &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; UI&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;IsMandatoryProgramPending
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;While&lt;/SPAN&gt; bIsMandatoryProgramPending
        WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Sleep&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008c00"&gt;10000&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
        bIsMandatoryProgramPending &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; UI&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;IsMandatoryProgramPending
        WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"DEBUG: Program is running, sleeping"&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;WEnd&lt;/SPAN&gt;
    WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"DEBUG: Running program: "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; o&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Name&lt;/SPAN&gt;
    UI&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ExecuteProgram o&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ID&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; o&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;PackageID&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;True&lt;/SPAN&gt;
    bProgramComplete &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;false&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;While&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Not&lt;/SPAN&gt; bProgramComplete
        WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"DEBUG: Checking if "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; o&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;" has completed running..."&lt;/SPAN&gt;
        WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Sleep&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008c00"&gt;10000&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; p &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; UI&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;GetProgram&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;o&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ID&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; o&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;PackageID&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; p&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;LastRunTime &lt;SPAN style="COLOR: #808030"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;&amp;gt;&lt;/SPAN&gt; o&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;LastRunTime &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
            WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"DEBUG: "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; o&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;" has completed running..."&lt;/SPAN&gt;
            bProgramComplete &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;true&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;WEnd&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5429038" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item><item><title>The SMS MP for SCOM 2007 does not work properly if the SMS server is not installed to C:\SMS</title><link>http://blogs.msdn.com/rslaten/archive/2007/09/19/the-sms-mp-for-scom-2007-does-not-work-properly-if-the-sms-server-is-not-installed-to-c-sms.aspx</link><pubDate>Wed, 19 Sep 2007 20:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4999450</guid><dc:creator>rslaten</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/4999450.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=4999450</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=4999450</wfw:comment><description>&lt;P&gt;The SMS MP Guide actually tells you this:&lt;BR&gt;&lt;BR&gt;&lt;EM&gt;"To specify the location of the SMS installation folder the script uses a system environment variable on the SMS site server. The administrator must create the %SMS_INSTALL_DIR_PATH% environment variable as a system environment variable so that the MOM Agent running under any user context has access to the log files. The script will then look in the %SMS_INSTALL_DIR_PATH%\Logs directory for the sender.log and distmgr.log files. For more information about setting system environment variables, see the system environment variable web page (&amp;lt;&lt;/EM&gt;&lt;A href="http://go.microsoft.com/fwlink/?LinkId=92316" mce_href="http://go.microsoft.com/fwlink/?LinkId=92316"&gt;&lt;EM&gt;http://go.microsoft.com/fwlink/?LinkId=92316&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;&amp;gt;). &lt;BR&gt;In order for the MOM Health Agent to use this system environment variable the SMS Site Server may need to be restarted."&lt;/EM&gt;&lt;BR&gt;&lt;BR&gt;This seems easy enough, but what if you have&amp;nbsp;thousands of&amp;nbsp;site servers?&amp;nbsp; My co-worker, Lenny Wile, ran into such a situation with a customer.&amp;nbsp; Obviously at this point we need an automated method of setting this environment variable.&amp;nbsp; Using SMS or SCOM&amp;nbsp;a script&amp;nbsp;such as this&amp;nbsp;could be run on each site server to set the environment variable appropriately:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Set oWMI = GetObject("winMgmts:root\default:StdRegProv")&lt;BR&gt;oWMI.GetStringValue &amp;amp;H80000002,"SOFTWARE\Microsoft\SMS\Setup","Installation Directory",sPath&lt;BR&gt;Set oWMI = GetObject("winMgmts:root\cimv2:Win32_Environment")&lt;BR&gt;Set oNewVar = oWMI.SpawnInstance_&lt;BR&gt;oNewVar.UserName = "&amp;lt;SYSTEM&amp;gt;"&lt;BR&gt;oNewVar.Name = "SMS_INSTALL_DIR_PATH"&lt;BR&gt;oNewVar.VariableValue = sPath&lt;BR&gt;oNewVar.Put_&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For your reference, here is one of the errors you might see if this variable isn't set appropriately:&lt;BR&gt;&lt;BR&gt;&lt;EM&gt;Error opening log file directory&lt;BR&gt;&lt;/EM&gt;&lt;EM&gt;Directory = %SMS_INSTALL_DIR_PATH%\Logs&lt;BR&gt;&lt;/EM&gt;&lt;EM&gt;Error: 0x80070003 &lt;BR&gt;Details: The system cannot find the path specified.&lt;BR&gt;One or more workflows were affected by this. &lt;BR&gt;&lt;/EM&gt;&lt;EM&gt;Workflow name: SMS_2003_Component__The_sender_cannot_connect_to_remote_site_over_the_LAN__Advanced_Security__4_Rule &lt;BR&gt;Instance name: Microsoft.SMS.2003.Microsoft_SMS_2003_Site_Servers_Installation &lt;BR&gt;Instance ID: {34B6B4DF-3EF9-A320-7AD1-69EF7A68A288}&lt;/EM&gt; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4999450" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category><category domain="http://blogs.msdn.com/rslaten/archive/tags/SCOM+2007/default.aspx">SCOM 2007</category></item><item><title>How the SMS 2003 Advanced Client Creates Delta Inventory</title><link>http://blogs.msdn.com/rslaten/archive/2007/09/18/how-the-sms-2003-advanced-client-creates-delta-inventory.aspx</link><pubDate>Tue, 18 Sep 2007 22:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4868840</guid><dc:creator>rslaten</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/4868840.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=4868840</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=4868840</wfw:comment><description>&lt;P&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;I have recently done some research on exactly how inventory is generated, including deltas, and have listed the information below.&amp;nbsp; This information can be obtained by monitoring the inventory agent logs, verbose WMI logs, and applicable inventory WMI classes: &lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Instruction to run inventory comes from an instance of InventoryAction.&amp;nbsp; This specifies full, delta, or resync report type. &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;The state of each inventory action is stored in the InventoryActionStatus class. &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Inventory history is stored in a class named after the inventory type (the C00…01 number for hinv) &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Each instance is of the InventoryReport class &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;When inventory starts… (hinv in this example) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;If a delta is being specified, make sure a full report has already been generated (checks the InventoryActionStatus class) &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Prepares the applicable history class (deletes all non-current reports) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;New instances are given a 'New' state &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Updated instances are given an 'Updated' state &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Instances that don't change are given a 'Verified' state &lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Inventory is reported: Only 'New', 'Deleted', and 'Updated' instances are reported for deltas &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Cleans up applicable history class (creates 'Current' reports for all 'New', 'Updated', and 'Verified' reports) &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Sends inventory report via messaging system &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Updates the InventoryActionStatus class &lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4868840" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item><item><title>How to Delete an Assignment from an SMS 2003 Advertisement</title><link>http://blogs.msdn.com/rslaten/archive/2007/09/18/how-to-delete-an-assignment-from-an-sms-2003-advertisement.aspx</link><pubDate>Tue, 18 Sep 2007 21:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4984074</guid><dc:creator>rslaten</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/4984074.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=4984074</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=4984074</wfw:comment><description>&lt;P&gt;I recently worked on an issue where a customer was trying to programmatically delete a mandatory assignment from an SMS 2003 advertisement. I saw that &lt;A href="http://www.microsoft.com/technet/prodtechnol/sms/sms2003/maintain/smsscript/script23.mspx?mfr=true" mce_href="http://www.microsoft.com/technet/prodtechnol/sms/sms2003/maintain/smsscript/script23.mspx?mfr=true"&gt;adding an assignment&lt;/A&gt; is a very easy and documented task, however deleting the same assignment is not. &lt;/P&gt;
&lt;P&gt;Unfortunately I was only able to work on the issue for a few hours because I was going on vacation but one of my peers, David Stewart, figured it out while I was out. I thought this example would be useful for anyone looking to delete an assignment using a script. &lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #696969"&gt;' Parse cmd line args&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;' ==============================&lt;/SPAN&gt;
sSiteCode &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Arguments&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008c00"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
sAdvertID &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Arguments&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008c00"&gt;1&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;' Connect to local site provider&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;' ==============================&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; objSWbemLocator &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;CreateObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"WbemScripting.SWbemLocator"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; objSWbemServices &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; objSWbemLocator&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ConnectServer&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"root\sms"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; ProviderLoc &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; objSWbemServices&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;InstancesOf&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"SMS_ProviderLocation"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Each&lt;/SPAN&gt; Location In ProviderLoc
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; Location&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ProviderForLocalSite &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;True&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; objSWbemServices &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; objSWbemLocator&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ConnectServer&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;Location&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Machine&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"root\sms\site_"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;+&lt;/SPAN&gt; Location&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SiteCode&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; objSWbemLocator &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Nothing&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; ProviderLoc &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Nothing&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;' Retrieve the advertisment instance of concern&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;' =============================================&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; objAdvert &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; objSWbemServices&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"SMS_Advertisement.AdvertisementID='"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; sAdvertID &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"'"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;' Display advertisement properties&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;' ================================&lt;/SPAN&gt;
WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"ActionInProgress = "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; objAdvert&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ActionInProgress
WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"AdvertFlags = "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; objAdvert&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;AdvertFlags
WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"AdvertisementID = "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; objAdvert&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;AdvertisementID
WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"AdvertisementName = "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; objAdvert&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;AdvertisementName
WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"CollectionID = "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; objAdvert&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;CollectionID
WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"Comment = "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; objAdvert&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Comment
WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"Assigned Schedule = {"&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;' Display advertisement properties&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;' ================================&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;set&lt;/SPAN&gt; Advertisement_Properties &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; objAdvert&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Properties_ &lt;SPAN style="COLOR: #696969"&gt;'get property set&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;set&lt;/SPAN&gt; AssignedScheduleArray &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; Advertisement_Properties&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Item&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"AssignedSchedule"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;' Display advertisement properties&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;' ================================&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Dim&lt;/SPAN&gt; replacementScheduleArray&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;

intSize &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;0&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;' Loop through current assignments, copy them to new array to update advertisement instance.&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;' Leave any assignments we want to remove out of the new array.&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;' ==========================================================================================&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;for&lt;/SPAN&gt; i &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;0&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;to&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;UBound&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;AssignedScheduleArray&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;

    &lt;SPAN style="COLOR: #696969"&gt;'Retrieve next schedule token from instance array&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: #696969"&gt;'================================================&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Dim&lt;/SPAN&gt; SMS_ScheduleToken
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; SMS_ScheduleToken &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; AssignedScheduleArray&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;i&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    
    &lt;SPAN style="COLOR: #696969"&gt;'Display schedule token, ask if it should be deleted.&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: #696969"&gt;'====================================================&lt;/SPAN&gt;
    WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo AssignedScheduleArray&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;" "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; i &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;":"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; SMS_ScheduleToken&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;GetObjectText_&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;MsgBox&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"Do you want to delete this assignment?"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;4&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"Assignment:"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; SMS_ScheduleToken&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;StartTime&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;&amp;gt;&lt;/SPAN&gt; vbYes &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
        
        &lt;SPAN style="COLOR: #696969"&gt;'Not deleting this schedule token, add it to the replacement array.&lt;/SPAN&gt;
        &lt;SPAN style="COLOR: #696969"&gt;'==================================================================&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;redim&lt;/SPAN&gt; preserve replacementScheduleArray&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;intSize&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;set&lt;/SPAN&gt; replacementScheduleArray&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;intSize&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; SMS_ScheduleToken&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Clone_&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
        intSize &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; intSize &lt;SPAN style="COLOR: #808030"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;1&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;end&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;if&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;next&lt;/SPAN&gt;
WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"}"&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'Update the advertisement instance with the replacement schedule token array&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;'===========================================================================&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;IntSize &lt;SPAN style="COLOR: #808030"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;1&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;then&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: #696969"&gt;'We removed all the schedule tokens.&lt;/SPAN&gt;
    objAdvert&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Properties_&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Item&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"AssignedSchedule"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; null   
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;else&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: #696969"&gt;' There is at least one value to keep&lt;/SPAN&gt;
    objAdvert&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Properties_&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Item&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"AssignedSchedule"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; replacementScheduleArray
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;end&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;if&lt;/SPAN&gt;
objAdvert&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Put_&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;

&lt;/PRE&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4984074" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item><item><title>The Mystery of the Lost Hardware Inventory</title><link>http://blogs.msdn.com/rslaten/archive/2007/09/18/the-mystery-of-the-lost-hardware-inventory.aspx</link><pubDate>Tue, 18 Sep 2007 20:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4868994</guid><dc:creator>rslaten</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/4868994.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=4868994</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=4868994</wfw:comment><description>&lt;P&gt;In large environments, with tens of thousands of SMS 2003 clients, inventory may get "lost" for various reasons. An example of a lost inventory is below: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;An SMS 2003 Advanced Client reports a full inventory upon install &lt;/LI&gt;
&lt;LI&gt;The client continues to report delta inventory of changes &lt;/LI&gt;
&lt;LI&gt;The client reports a delta inventory but that inventory gets "lost" &lt;/LI&gt;
&lt;LI&gt;The client continues to report delta inventory but the changes in the "lost" inventory never appear in the database &lt;/LI&gt;
&lt;LI&gt;The client gets resync'd, sending up a full inventory, and the changes that were "lost" now appear &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;BR&gt;Clients don't get resync'd under normal conditions therefore that inventory may not ever appear in the database. This can become an issue for inventory items such as security updates (staying applicable in the database but not applicable on the client). System Center Configuration Manager 2007 contains architectural changes which prevent this scenario from occurring. Specifically SCCM 2007 serializes software and hardware inventory reporting so that missing reports, which are based on serial numbers instead of timestamps, trigger a re-synchronization of inventory at the client.&lt;BR&gt;&lt;BR&gt;So if you don't plan on upgrading to SCCM 2007 in the near future how might you prevent inventory from being "lost"? I documented some steps that should assist with detecting, and possibly resolving, the rare scenario when clients send up inventory that somehow disappears before getting loaded into the database. These steps are simply an example of how one might do this and the scripts are not tested and do not contain any type of error handling, logging, or reporting.&lt;BR&gt;&lt;BR&gt;&lt;STRONG&gt;Step # 1 – Modify the SMS_DEF.MOF &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Modify the Win32_OperatingSystem section of the MOF to report "LocalDateTime".&amp;nbsp; This is required because the "Workstation Status" section shows "Last Hardware Scan" but there isn't a way to keep the history of this data therefore we need a consistent time we can key in on that writes to a history table. &lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;Create a new class in the SMS_DEF.MOF to pick up a new WMI class which we'll create a populate later: &lt;/DIV&gt;
&lt;P style="MARGIN-LEFT: 18pt"&gt;//SMSInventoryHistory&lt;BR&gt;&amp;nbsp;[SMS_Report(TRUE),&lt;BR&gt;SMS_Group_Name("SMS Inventory"),&lt;BR&gt;SMS_Class_ID("MICROSOFT|SMS_INVENTORY|1.0"),&lt;BR&gt;Namespace("&lt;A href="file://root/SMSINVENTORY" mce_href="file:///\\root\SMSINVENTORY"&gt;\\\\\\\\.\\\\root\\\\SMSINVENTORY&lt;/A&gt;")]&lt;BR&gt;class InvHistory: SMS_Class_Template&lt;BR&gt;{&lt;BR&gt;[SMS_Report(TRUE),key]&lt;BR&gt;datetime&amp;nbsp;&amp;nbsp; ScanTime;&lt;BR&gt;[SMS_Report(TRUE)]&lt;BR&gt;uint32&amp;nbsp;&amp;nbsp; KeyIncrement;&lt;BR&gt;[SMS_Report(TRUE)]&lt;BR&gt;string&amp;nbsp;&amp;nbsp; ScanType;&lt;BR&gt;}; &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;Notice the KeyIncrement field.&amp;nbsp; This is there because we want to report every instance of this class for every inventory.&amp;nbsp; It is for this reason that we don't need history enabled for this class so it can be disabled by using &lt;A href="http://support.microsoft.com/kb/836432/en-us" mce_href="http://support.microsoft.com/kb/836432/en-us"&gt;KB836432&lt;/A&gt; (This still applies to SMS 2003 and likely SCCM 2007). &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Step # 2 – Create a recurring advertisement, which should probably run at least twice as often as hardware inventory (if not more), which runs client.vbs &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Creates a new "SMSInventory" class under "root" if it doesn't exist&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;Gets the last hardware scan from root\ccm\invagt:InventoryActionStatus&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;Creates a new instance of InvHistory in the SMSInventory namespace if the hardware scan is new&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;If the inventory is already recorded then update the "KeyIncrement" field so SMS reports this in every delta&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;Cleans up any instances older than 14 days by default to keep the delta inventory from growing too large&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;DIV style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #696969"&gt;'client.vbs&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;'rslaten&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;'08/15/2007&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'Determines when to clean out old inventory instances&lt;/SPAN&gt;
iDays &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;14&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'Connect to WMI locally&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oLocator &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;CreateObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"WbemScripting.sWbemLocator"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oSvc &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oLocator&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ConnectServer&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"root"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'Create a custom namespace to hold data if it doesn't already exist&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oNamespaces &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oSvc&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;InstancesOf&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"__namespace"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
bFound &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;False&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;each&lt;/SPAN&gt; oNamespace in oNamespaces
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; oNamespace&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"SMSInventory"&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
        bFound &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;True&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Exit&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;

&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Not&lt;/SPAN&gt; bFound &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oNamespace &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oSvc&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"__namespace"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oCustomNameSpace &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oNamespace&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SpawnInstance_
    oCustomNamespace&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"SMSInventory"&lt;/SPAN&gt;
    oCustomNamespace&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Put_&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;

    &lt;SPAN style="COLOR: #696969"&gt;'Create a custom class to hold data&lt;/SPAN&gt;
    wbemCimtypeUint32 &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;19&lt;/SPAN&gt;
    wbemCimtypeDatetime &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;101&lt;/SPAN&gt;
    wbemCimtypeString &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;8&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oWMI &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;GetObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"winmgmts:root\SMSInventory"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oClass &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oWMI&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    oClass&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Path_&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"InvHistory"&lt;/SPAN&gt;
    oClass&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Properties_&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;add &lt;SPAN style="COLOR: #0000e6"&gt;"ScanTime"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; wbemCimtypeDatetime
    oClass&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Properties_&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"ScanTime"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Qualifiers_&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;add &lt;SPAN style="COLOR: #0000e6"&gt;"key"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;true&lt;/SPAN&gt;
    oClass&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Properties_&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;add &lt;SPAN style="COLOR: #0000e6"&gt;"KeyIncrement"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; wbemCimtypeUint32
    oClass&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Properties_&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;add &lt;SPAN style="COLOR: #0000e6"&gt;"ScanType"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; wbemCimtypeString
    oClass&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Put_&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'Get timezone&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oSvc &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oLocator&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ConnectServer&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"root\cimv2"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; collTimeZone &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oSvc&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ExecQuery&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"select Bias, DaylightBias from Win32_TimeZone"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Each&lt;/SPAN&gt; oTimeZone in collTimeZone
    iTimeZone &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oTimeZone&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Bias &lt;SPAN style="COLOR: #808030"&gt;-&lt;/SPAN&gt; oTimeZone&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;DaylightBias
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'Get last Hinv report date and convert to local time&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oSvc &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oLocator&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ConnectServer&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"root\ccm\invagt"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
HActionID &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;""&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"{00000000-0000-0000-0000-000000000001}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;""&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oHinv &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oSvc&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"InventoryActionStatus.InventoryActionID="&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
    HActionID&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Const&lt;/SPAN&gt; CONVERT_TO_LOCAL_TIME &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;true&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;'dLastReportDate = ConvertToGMT(oHinv.LastReportDate)&lt;/SPAN&gt;
dLastReportDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oHinv&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;LastReportDate
dLastReportDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; WMIDateStringToDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dLastReportDate&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; dNewTime &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;CreateObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"WbemScripting.SWbemDateTime"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
dNewTime&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SetVarDate dLastReportDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; CONVERT_TO_LOCAL_TIME
dLastReportDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; dNewTime&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;GetVarDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;CONVERT_TO_LOCAL_TIME&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
dLastReportDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;DateAdd&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"n"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; iTimeZone&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; dLastReportDate&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
dLastReportDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; GetWMIDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dLastReportDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"+000"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'Set last Hinv report date&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oSvc &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oLocator&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ConnectServer&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"root\SMSInventory"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oHinvHistory &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oSvc&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;InstancesOf&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"InvHistory"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'First instance in class&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; oHinvHistory&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Count &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;0&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oHinv &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oSvc&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"InvHistory"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;SpawnInstance_
    oHinv&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ScanTime &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; dLastReportDate
    oHinv&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;KeyIncrement &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;0&lt;/SPAN&gt;
    oHinv&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ScanType &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"Hardware"&lt;/SPAN&gt;
    oHinv&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Put_&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Else&lt;/SPAN&gt;
    bFound &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;False&lt;/SPAN&gt;
    
    &lt;SPAN style="COLOR: #696969"&gt;'Calculate date to clean up old instances&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; dExpire &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;CreateObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"WbemScripting.SWbemDateTime"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    dExpire&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SetVarDate &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Now&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; CONVERT_TO_LOCAL_TIME
    dRegular &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; dExpire&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;GetVarDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;CONVERT_TO_LOCAL_TIME&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    dExpireDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;DateAdd&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"d"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;-&lt;/SPAN&gt;iDays&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; dRegular&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    dExpire&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SetVarDate dExpireDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; CONVERT_TO_LOCAL_TIME
    
    &lt;SPAN style="COLOR: #696969"&gt;'Updating all instances&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;each&lt;/SPAN&gt; oInstance in oHinvHistory
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; dLastReportDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ScanTime &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
            bFound &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;True&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
        
        &lt;SPAN style="COLOR: #696969"&gt;'Clean up old instances&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ScanTime &lt;SPAN style="COLOR: #808030"&gt;&amp;lt;&lt;/SPAN&gt; dExpire &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
            oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Delete_
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Else&lt;/SPAN&gt;
            &lt;SPAN style="COLOR: #696969"&gt;'Increment the KeyIncrement property to force SMS to pick&lt;/SPAN&gt;
            &lt;SPAN style="COLOR: #696969"&gt;'up the instance during inventory&lt;/SPAN&gt;
            oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;KeyIncrement &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;KeyIncrement &lt;SPAN style="COLOR: #808030"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;1&lt;/SPAN&gt;
            oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Put_
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;
    
    &lt;SPAN style="COLOR: #696969"&gt;'Create a new instance if needed&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Not&lt;/SPAN&gt; bFound &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oHinv &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oSvc&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"InvHistory"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;SpawnInstance_
        oHinv&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ScanTime &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; dLastReportDate
        oHinv&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;KeyIncrement &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;0&lt;/SPAN&gt;
        oHinv&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ScanType &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"Hardware"&lt;/SPAN&gt;
        oHinv&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Put_&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;    
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;

&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Function&lt;/SPAN&gt; ConvertToGMT&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dDate&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    ConvertToGMT &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; Replace&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"-000"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; iTimeZone&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Function&lt;/SPAN&gt;

&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Function&lt;/SPAN&gt; WMIDateStringToDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
     WMIDateStringToDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;CDate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Mid&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;5&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"/"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
     &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Mid&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;7&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"/"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Left&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;4&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
     &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;" "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Mid&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;9&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;":"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
     &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Mid&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;11&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;":"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Mid&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
     &lt;SPAN style="COLOR: #008c00"&gt;13&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Function&lt;/SPAN&gt;

&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Function&lt;/SPAN&gt; GetWMIDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;vd&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt;strOffset&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;On&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Error&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Resume&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;
    GetWMIDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; Year&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;vd&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; AddZero&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Month&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;vd&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; AddZero&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;Day&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;vd&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
            AddZero&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Hour&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;vd&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; AddZero&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Minute&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;vd&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
            AddZero&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Second&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;vd&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;".000000"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; strOffset
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Function&lt;/SPAN&gt;

&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Function&lt;/SPAN&gt; AddZero&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;pNum&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;On&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Error&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Resume&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; pNum &lt;SPAN style="COLOR: #808030"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008c00"&gt;9&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;then&lt;/SPAN&gt;
        AddZero &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"0"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; pNum
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Else&lt;/SPAN&gt; AddZero &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; pNum
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Function&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;STRONG&gt;Step # 3 – Periodically check to see if there is any missing hardware inventory by running server.vbs &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Queries the SMS database for OS LocalDateTime and the custom SMSInventory ScanTime&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;Compares the ScanTime to LocalDateTime, searching for missing LocalDateTime entries.&amp;nbsp; To find a match the LocalDateTime must be within 5 minutes from the ScanTime.&amp;nbsp; If any clients take longer than 5 minutes to complete a hardware inventory cycle then this may need to be increased.&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;For any ScanTime without a matching LocalDateTime, we display the fact that there is a missing inventory.&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;DIV style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #696969"&gt;'server.vbs&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;'rslaten&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #696969"&gt;'08/15/2007&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'Globals&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Dim&lt;/SPAN&gt; aClients&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; iClients&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; iInstanceCount&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; iTotal

&lt;SPAN style="COLOR: #696969"&gt;'Get SMS Namespace&lt;/SPAN&gt;
sSMSNameSpace &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; GetSMSNameSpace&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'Connect to site server&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oWMI &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;GetObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"winMgmts:"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; sSMSNameSpace&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'Query clients and create and array of client objects&lt;/SPAN&gt;
sQuery &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"select distinct SMS_R_System.Name, SMS_R_System.SMSUniqueIdentifier,"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: #0000e6"&gt;" SMS_G_System_SMS_INVENTORY.ScanTime, SMS_GH_System_OPERATING_SYSTEM.LocalDateTime"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: #0000e6"&gt;" from  SMS_R_System inner join SMS_G_System_SMS_INVENTORY on "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: #0000e6"&gt;"SMS_G_System_SMS_INVENTORY.ResourceID = SMS_R_System.ResourceId inner"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: #0000e6"&gt;" join SMS_GH_System_OPERATING_SYSTEM on "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: #0000e6"&gt;"SMS_GH_System_OPERATING_SYSTEM.ResourceID = SMS_R_System.ResourceId "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: #0000e6"&gt;"where SMS_G_System_SMS_INVENTORY.ScanTime is not NULL and "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: #0000e6"&gt;"SMS_GH_System_OPERATING_SYSTEM.LocalDateTime is not NULL"&lt;/SPAN&gt;

&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; aCollection &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oWMI&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ExecQuery&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;sQuery&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
iTotal &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; aCollection&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;count
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Each&lt;/SPAN&gt; oInstance In aCollection
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; sLastName &lt;SPAN style="COLOR: #808030"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;&amp;gt;&lt;/SPAN&gt; oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SMS_R_System&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Name&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
        &lt;SPAN style="COLOR: #696969"&gt;'Make sure this isn't the first iteration in the array&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; iInstanceCount &lt;SPAN style="COLOR: #808030"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;0&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
            &lt;SPAN style="COLOR: #696969"&gt;'Add to master array&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;ReDim&lt;/SPAN&gt; Preserve aClients&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;iClients&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; aClients&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;iClients&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oClient
            iClients &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; iClients &lt;SPAN style="COLOR: #808030"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;1&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
        
        &lt;SPAN style="COLOR: #696969"&gt;'Now create new client object&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oClient &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;New&lt;/SPAN&gt; Client
        oClient&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;sClient &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SMS_R_System&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Name&lt;/SPAN&gt;
        oClient&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;sGUID &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SMS_R_System&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SMSUniqueIdentifier
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
    
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; sLastScan &lt;SPAN style="COLOR: #808030"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;&amp;gt;&lt;/SPAN&gt; oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SMS_G_System_SMS_Inventory&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ScanTime &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
        oClient&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;AddSMSInventoryScanDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SMS_G_System_SMS_Inventory&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ScanTime&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
    
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; sLastOSScan &lt;SPAN style="COLOR: #808030"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;&amp;gt;&lt;/SPAN&gt; oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SMS_GH_System_OPERATING_SYSTEM&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;LocalDateTime &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
        oClient&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;AddOSScanDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SMS_GH_System_OPERATING_SYSTEM&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;LocalDateTime&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; 

    sLastName &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SMS_R_System&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Name&lt;/SPAN&gt;
    sLastScan &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SMS_G_System_SMS_Inventory&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ScanTime
    sLastOSScan &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oInstance&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;SMS_GH_System_OPERATING_SYSTEM&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;LocalDateTime
    iInstanceCount &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; iInstanceCount &lt;SPAN style="COLOR: #808030"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;1&lt;/SPAN&gt;
    
    &lt;SPAN style="COLOR: #696969"&gt;'If this is the last instance add it to the array&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; iInstanceCount &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; iTotal &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
        &lt;SPAN style="COLOR: #696969"&gt;'Add to master array&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;ReDim&lt;/SPAN&gt; Preserve aClients&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;iClients&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; aClients&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;iClients&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oClient
        iClients &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; iClients &lt;SPAN style="COLOR: #808030"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;1&lt;/SPAN&gt;    
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'Loop through clients in memory to check for missing inventory&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;each&lt;/SPAN&gt; oClient in aClients
    aScans &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oClient&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;aScans
    WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"******************************************"&lt;/SPAN&gt;
    WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"Client = "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; oClient&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;sClient
    WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"GUID = "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; oClient&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;sGUID
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;each&lt;/SPAN&gt; oScan in oClient&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;aScans
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;not&lt;/SPAN&gt; oScan&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;isOS &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oMatch &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;new&lt;/SPAN&gt; Match
            oMatch&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dScan &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; WMIDateStringToDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;oScan&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dDate&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
            oMatch&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;bMatch &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;false&lt;/SPAN&gt;
            
            &lt;SPAN style="COLOR: #696969"&gt;'Find a matching OS time (look for match within 5 minutes)&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;each&lt;/SPAN&gt; oTime in aScans
                &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; oTime&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;isOS &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
                    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;DateDiff&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"n"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; oMatch&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dScan&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
                        WMIDateStringToDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;oTime&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dDate&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;5&lt;/SPAN&gt; and &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
                        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;DateDiff&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"n"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; oMatch&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dScan&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
                        WMIDateStringToDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;oTime&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dDate&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;-&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008c00"&gt;5&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;             
                        oMatch&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dOS &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; WMIDateStringToDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;oTime&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dDate&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
                        oMatch&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;bMatch &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;true&lt;/SPAN&gt;
                    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
                &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;
            
            &lt;SPAN style="COLOR: #696969"&gt;'Make sure we found a match&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;not&lt;/SPAN&gt; oMatch&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;bMatch &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
                WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"*PROBLEM FOUND*"&lt;/SPAN&gt;
                WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"SMS Inventory Report = "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; oMatch&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dScan
                WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"*NO MATCHING OS DATE FOUND*"&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Else&lt;/SPAN&gt;
                WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo oMatch&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dScan &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;" = "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; oMatch&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dOS
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;
    WScript&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;Echo &lt;SPAN style="COLOR: #0000e6"&gt;"******************************************"&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #696969"&gt;'Get regular date&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Function&lt;/SPAN&gt; WMIDateStringToDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    WMIDateStringToDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;CDate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Mid&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;5&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"/"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Mid&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;7&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;"/"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Left&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;4&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
            &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;" "&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Mid&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;9&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;":"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
                &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Mid&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;11&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000e6"&gt;":"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Mid&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtmInstallDate&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
                    &lt;SPAN style="COLOR: #008c00"&gt;13&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Function&lt;/SPAN&gt;


&lt;SPAN style="COLOR: #696969"&gt;'Gets SMS Namespace from local site server&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Function&lt;/SPAN&gt; GetSMSNameSpace&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; refWMI &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;GetObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"winMgmts:\root\sms"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;    
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; colNameSpaceQuery &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; refWMI&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;ExecQuery&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;"select * from SMS_ProviderLocation"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Each&lt;/SPAN&gt; refitem in colNameSpaceQuery
        GetSMSNameSpace &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; refitem&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;NamespacePath
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Function&lt;/SPAN&gt;

&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Class&lt;/SPAN&gt; Client
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Public&lt;/SPAN&gt; aScans&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Private&lt;/SPAN&gt; i
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Public&lt;/SPAN&gt; sClient
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Public&lt;/SPAN&gt; sGUID
    
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Sub&lt;/SPAN&gt; AddOSScanDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dScanDate&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
        &lt;SPAN style="COLOR: #696969"&gt;'Check for duplicates&lt;/SPAN&gt;
        bFound &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;false&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Each&lt;/SPAN&gt; oScan in aScans
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; dScanDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oScan&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dDate And &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
                oScan&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;isOS &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;true&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
                bFound &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;true&lt;/SPAN&gt;
                &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Exit&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;
        
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Not&lt;/SPAN&gt; bFound &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oScan &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;New&lt;/SPAN&gt; Scan
            oScan&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; dScanDate
            oScan&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;isOS &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;true&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;ReDim&lt;/SPAN&gt; Preserve aScans&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;i&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; aScans&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;i&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oScan
            i &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; i &lt;SPAN style="COLOR: #808030"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;1&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Sub&lt;/SPAN&gt;
    
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Sub&lt;/SPAN&gt; AddSMSInventoryScanDate&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dScanDate&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
        &lt;SPAN style="COLOR: #696969"&gt;'Check for duplicates&lt;/SPAN&gt;
        bFound &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;false&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Each&lt;/SPAN&gt; oScan in aScans
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; dScanDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oScan&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dDate And &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;_&lt;/SPAN&gt;
                oScan&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;isOS &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;false&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;
                bFound &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;true&lt;/SPAN&gt;
                &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Exit&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;For&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Next&lt;/SPAN&gt;
        
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Not&lt;/SPAN&gt; bFound &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Then&lt;/SPAN&gt;        
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; oScan &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;New&lt;/SPAN&gt; Scan
            oScan&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;dDate &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; dScanDate
            oScan&lt;SPAN style="COLOR: #008c00"&gt;.&lt;/SPAN&gt;isOS &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0f4d75"&gt;false&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;ReDim&lt;/SPAN&gt; Preserve aScans&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;i&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;
            &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Set&lt;/SPAN&gt; aScans&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;i&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oScan
            i &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; i &lt;SPAN style="COLOR: #808030"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;1&lt;/SPAN&gt;    
        &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;If&lt;/SPAN&gt;
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Sub&lt;/SPAN&gt;
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Class&lt;/SPAN&gt;

&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Class&lt;/SPAN&gt; Scan
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Public&lt;/SPAN&gt; dDate
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Public&lt;/SPAN&gt; isOS
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Class&lt;/SPAN&gt;

&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Class&lt;/SPAN&gt; Match
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Public&lt;/SPAN&gt; dScan
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Public&lt;/SPAN&gt; dOS
    &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Public&lt;/SPAN&gt; bMatch
&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;End&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;Class&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;STRONG&gt;Step # 4 – Force a resync on the clients that have "lost" inventory &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The method to delete the local inventory cache is the &lt;A href="http://www.microsoft.com/technet/prodtechnol/sms/sms2003/maintain/smsscript/script31.mspx?mfr=true" mce_href="http://www.microsoft.com/technet/prodtechnol/sms/sms2003/maintain/smsscript/script31.mspx?mfr=true"&gt;known and documented method&lt;/A&gt; of doing this. &lt;/LI&gt;
&lt;LI&gt;There may be a way to use the MP API to create a server side policy, but this would require significant work and a non-script (C++) application.&amp;nbsp; Internally, as you can see with SQL profiler, we execute the sp_RC_InvResync stored procedure but as you know executing these directly isn't recommended or supported. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;These examples do not contain error checking and need to be optimized for performance.&amp;nbsp; The examples have also only been tested in a very small test environment using only the scenario documented at the top of this post.&amp;nbsp; If this method is to be used in a production environment more code work and testing needs to be done, particularly on the server end, to improve the detection logic, add history to which clients resyncs have been sent to, and add reporting capabilities. &lt;/P&gt;
&lt;P&gt;**Steps 3 and 4 might not be required.&amp;nbsp; During testing I found a potentially unforeseen benefit of running the client.vbs script on clients with "lost" inventory.&amp;nbsp; Since every instance of the InvHistory class is reported during every inventory, when an instance is listed as "Update" but isn't in the database, dataloader will automatically request a resync for that client.&amp;nbsp; More testing of this finding needs to be done to verify that this will work, and if it does it should simplify detecting which clients have lost inventory** &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4868994" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category><category domain="http://blogs.msdn.com/rslaten/archive/tags/SCCM+2007/default.aspx">SCCM 2007</category></item><item><title>Bit Fields and the SMS_Advertisement Class</title><link>http://blogs.msdn.com/rslaten/archive/2007/07/17/bit-fields-and-the-sms-advertisement-class.aspx</link><pubDate>Tue, 17 Jul 2007 22:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3922159</guid><dc:creator>rslaten</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/3922159.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=3922159</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=3922159</wfw:comment><description>&lt;P&gt;I recently worked on an issue involving a customer attempting to create a mandatory Advert using a C# application. The advertisement worked but wasn't mandatory even though it looked to be in the SMS Admin console. There was also some confusion as to how the bit field properties work and why the advert wasn't mandatory. The customer had noticed that the TimeFlags value in the SMS_Advertisement class was different in their custom application than one created by the SMS Admin Console. I sent the following explanation which I wanted to share: &lt;/P&gt;
&lt;P&gt;Dear &amp;lt;customer&amp;gt;, &lt;/P&gt;
&lt;P&gt;I can't debug your custom application but I did end up having to create a test application (code attached) that emulates what the &amp;lt;custom&amp;gt; application does so I could see what your instance of SMS_Advertisement looks like.&amp;nbsp; After viewing the differences I saw that an advert created in the SMS Admin console, and one created with the &amp;lt;custom&amp;gt; application, were different and it wasn't just the TimeFlags property.&amp;nbsp; The SMS Admin console uses the SDK just like your program so it is just a matter of seeing that there is a difference between the two classes and informing the developer of the custom application of the difference so they can correct it.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;There was also some confusion over how the TimeFlags property works so I explain this below: &lt;/P&gt;
&lt;P&gt;SMS uses bit fields for lots of on/off settings.&amp;nbsp; The TimeFlags property is no exception.&amp;nbsp; The TimeFlags property is a bit field, which is actually just a set of boolean flags.&amp;nbsp; By default, when a regular mandatory advertisement is created through the SMS Admin console, a decimal value of 8209 is assigned to the TimeFlags property.&amp;nbsp; 8209 converted to binary is "10000000010001".&amp;nbsp; This is the important number. &lt;/P&gt;
&lt;P&gt;Here is what the SDK says about the TimeFlags property: &lt;/P&gt;
&lt;P&gt;TimeFlags &lt;BR&gt;Datatype: uint32&lt;BR&gt;Access type: Read-only&lt;BR&gt;Qualifiers: Bits &lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Reserved for internal use. Duplicates the information in the time-related properties. For example, ENABLE_PRESENT is set when PresentTimeEnabled equals TRUE. Bit flags are as follows: &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;ENABLE_PRESENT (bit 0 = 1)&lt;BR&gt;ENABLE_EXPIRATION (bit 1 = 2)&lt;BR&gt;ENABLE_AVAILABLE (bit 2 = 4)&lt;BR&gt;ENABLE_UNAVAILABLE (bit 3 = 8)&lt;BR&gt;ENABLE_MANDATORY (bit 4 = 16)&lt;BR&gt;GMT_PRESENT (bit 8 = 256)&lt;BR&gt;GMT_EXPIRATION (bit 9 = 512)&lt;BR&gt;GMT_AVAILABLE (bit 10 = 1024)&lt;BR&gt;GMT_UNAVAILABLE (bit 11 = 2048)&lt;BR&gt;GMT_MANDATORY (bit 12 = 4096) &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;So now we know what the real settings are.&amp;nbsp; You count from right to left of the binary number ignoring the first bit.&amp;nbsp; As you can see 8209 really means ENABLE_MANDATORY.&amp;nbsp; In the case of 8193 (10000000000001) none of the bits are on.&amp;nbsp; I wrote a test application that emulates what the &amp;lt;custom&amp;gt; program does (I couldn't view the differences between an advert created by the console and one by their application without doing this) and also created a test mandatory advert using the SMS admin console.&amp;nbsp; I compared the potentially relevant differences and those are noted below: &lt;/P&gt;
&lt;P&gt;AdvertFlags Property:&lt;BR&gt;&amp;lt;customer&amp;gt; App. is set to 67108864 (100000000000000000000000000)&lt;BR&gt;Admin Console is set to 0&lt;BR&gt;*This shouldn't matter since none of the flags are enabled anyway &lt;/P&gt;
&lt;P&gt;AssignedScheduleEnabled Property:&lt;BR&gt;&amp;lt;custom&amp;gt; App. is set to False&lt;BR&gt;Admin Console is set to True&lt;BR&gt;Per SDK: Indicates whether the schedule defined in AssignedSchedule is active. The default value is FALSE. &lt;/P&gt;
&lt;P&gt;I changed the test application by setting the AssignedScheduleEnabled property and it started working and the TimeFlags property was now set to ENABLE_MANDATORY.&amp;nbsp; Basically, the problem appears to be that the advertisement created with the &amp;lt;custom&amp;gt; program isn't ever being set to mandatory. &lt;/P&gt;
&lt;P&gt;Thanks, &lt;/P&gt;
&lt;P&gt;Russ &lt;/P&gt;
&lt;P&gt;Here is the code in the test application that I wrote to emulate what the customer was doing: &lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;using&lt;/SPAN&gt; System&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;using&lt;/SPAN&gt; System&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Collections&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Generic&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;using&lt;/SPAN&gt; System&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Text&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;using&lt;/SPAN&gt; Microsoft&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;SystemsManagementServer&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Automation&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;namespace&lt;/SPAN&gt; CreateAdvert&lt;BR&gt;&lt;SPAN style="COLOR: #800080"&gt;{&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;class&lt;/SPAN&gt; Program&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #800080"&gt;{&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;static&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;void&lt;/SPAN&gt; Main&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;[&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;]&lt;/SPAN&gt; args&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #800080"&gt;{&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SMSProvider oProvider &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;new&lt;/SPAN&gt; SMSProvider&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;server&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;administrator&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;password&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SMSPackage oPackage &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oProvider&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Packages&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Get&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;CEN00001&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SMSProgram oProgram &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oPackage&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Programs&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Create&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;Notepad&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;notepad.exe&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oProgram&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;AllowUserToInteractWithProgram &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;true&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oProgram&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;RunMode &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; ProgramRunModes&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Normal&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oProgram&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;RunOnAnyPlatform &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;true&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oProgram&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;UserRequirements &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; UserRequirementsFlags&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;OnlyRunWhenUserLoggedOn&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oProgram&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Save&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SMSCollection oCollection &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oProvider&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Collections&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Get&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;SMS00001&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SMSAdvertisement oAdvert &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; oProvider&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Advertisements&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Create&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;Test&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; oCollection&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; oProgram&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oAdvert&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Comment &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000e6"&gt;Test&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oAdvert&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;PresentTimeEnabled &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;true&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateTime now &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; DateTime&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Now&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oAdvert&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;PresentTime &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; now&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateTime tomorrow &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; DateTime&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Now&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;AddDays&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008c00"&gt;1&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oAdvert&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;IncludeSubCollections &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;false&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oAdvert&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;MandatoryOverSlowLinks &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;true&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oAdvert&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;WhenLocalDPAvailable &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; LocalDPOptions&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;DownloadFromDistributionPoint&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oAdvert&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;AssignedScheduleEnabled &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;true&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;; &lt;SPAN style="COLOR: #696969"&gt;//this is what was missing&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateTime dtTenMin &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; DateTime&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Now&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;AddMinutes&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008c00"&gt;10&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SMSScheduleToken_NonRecurring tokNonRec &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;new&lt;/SPAN&gt; SMSScheduleToken_NonRecurring&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;new&lt;/SPAN&gt; DateTime&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;dtTenMin&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Year&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; dtTenMin&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Month&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; dtTenMin&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Day&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; dtTenMin&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Hour&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; dtTenMin&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Minute&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; dtTenMin&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Second&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oAdvert&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;AssignedSchedules&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Add&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;tokNonRec&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateTime later &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; DateTime&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Now&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;AddYears&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008c00"&gt;1&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oAdvert&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;ExpirationTime &lt;SPAN style="COLOR: #808030"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #800000"&gt;new&lt;/SPAN&gt; DateTime&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;later&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Date&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Year&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; later&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Date&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Month&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; later&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Date&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Day&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;5&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: #008c00"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oAdvert&lt;SPAN style="COLOR: #808030"&gt;.&lt;/SPAN&gt;Save&lt;SPAN style="COLOR: #808030"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808030"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800080"&gt;;&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #800080"&gt;}&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #800080"&gt;}&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="COLOR: #800080"&gt;}&lt;/SPAN&gt;&lt;BR&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3922159" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item><item><title>Finding Overlapping Boundaries in SMS (SMSBoundaries v1.42)</title><link>http://blogs.msdn.com/rslaten/archive/2007/03/20/finding-overlapping-boundaries-in-sms-smsboundaries-v1-42.aspx</link><pubDate>Tue, 20 Mar 2007 18:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1919983</guid><dc:creator>rslaten</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/1919983.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=1919983</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=1919983</wfw:comment><description>&lt;P&gt;Have you ever found yourself in a situation where an SMS Advanced client ends up getting policy or advertisements from the wrong site, or they are using the wrong MP/DP?&amp;nbsp; This is a very common issue for our customers and determining root cause can be difficult.&amp;nbsp; When AD Sites and IP Ranges were included in SMS 2003 overlapping boundary issues became much more common and much harder to control.&amp;nbsp; In many larger environments the administrator managing SMS is not responsible for managing AD sites causing even more confusion. &lt;/P&gt;
&lt;P&gt;Back in early 2005 I wrote an executable called SMSBoundaries.exe that is used to troubleshoot such issues.&amp;nbsp; SMSBoundaries.exe would query AD and convert all subnets specified in any SMS AD Site boundary to IP ranges.&amp;nbsp; It would then convert those ranges to integer format and look for overlaps between all boundaries.&amp;nbsp; This tool is still widely used by Microsoft support but it has several flaws.&amp;nbsp; One of the flaws is that it won't find overlapping situations due to orphaned data left in AD, or data from a separate hierarchy.&amp;nbsp; Another flaw is that it couldn't really find all the possible overlaps if SMS Subnets were specified because it didn't know the subnet mask of the clients (hence it couldn't really derive the appropriate IP Range to use for comparison). &lt;/P&gt;
&lt;P&gt;Despite these flaws I intended to make sure this tool was included in the next release of the toolkit (then toolkit3).&amp;nbsp; Obviously this toolkit never came out therefore the tool remained for use by only Microsoft support to help solve issues related to overlapping boundaries. &lt;/P&gt;
&lt;P&gt;Over the years I've been asked to convert this tool to vbscript.&amp;nbsp; The reason for doing this is because it's easier to include in other tools support uses to troubleshoot SMS (like the new version of MPSReports that support uses to collect technical data to diagnose customer issues) and it's easier to get in more people's hands. &lt;/P&gt;
&lt;P&gt;Back in October 2006 I converted the tool to vbscript and added the missing functionality to the new tool.&amp;nbsp; I have since added a few more things with the help of Jeff Tondt from Microsoft Consulting Services.&amp;nbsp; This script is intended to be an example demonstrating how to find overlapping SMS boundaries in your environment.&amp;nbsp; Like the rest of the examples on this blog this script is not supported.&amp;nbsp; Here is a description of this script: &lt;/P&gt;
&lt;P&gt;Syntax: &lt;/P&gt;
&lt;P&gt;Cscript.exe smsboundaries.vbs verbose &amp;lt;clientname&amp;gt; &lt;/P&gt;
&lt;P&gt;The verbose and &amp;lt;clientname&amp;gt; parameters are both optional. &lt;/P&gt;
&lt;P&gt;The output of the script is an XML and Log file created in the same directory where the tool is run.&amp;nbsp; The tool should be run on the SMS Central Site using an account that has rights to the SMS Central site, AD, and the client if one is specified on the command line.&amp;nbsp; The XML file should be used for general viewing and the log file should be used when troubleshooting an issue with the script, viewing which boundaries are overlapping in the case where you have many overlapping boundaries, or when looking to see what sites a client specified on the command line falls under. &lt;/P&gt;
&lt;P&gt;How it works: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Gets Command Line arguments &lt;/LI&gt;
&lt;LI&gt;Starts logging to SMSBoundaries.log (In SMS Logging format so SMS Trace can be used to view the log). &lt;/LI&gt;
&lt;LI&gt;Gets the site boundaries of all sites in the hierarchy by querying the SMS Central Site database through the SMS WMI SDK provider.&amp;nbsp; Each boundary is stored in an array of Boundary objects.&amp;nbsp; For the IP Ranges the script automatically converts the range to an integer IP Range which is later used to find overlapping boundaries. &lt;/LI&gt;
&lt;LI&gt;If any SMS Subnets are configured the script gets the IP subnet information for every client that reports up through this hierarchy. &lt;/LI&gt;
&lt;LI&gt;For every SMS Subnet specified, the script finds the first client that falls in this subnet and creates a new Boundary object using the client IP information gathered previously.&amp;nbsp; The script will create additional client Boundary objects for any clients that fall within that subnet but have a different range (so they have a different subnet mask).&amp;nbsp; This process is important otherwise the script couldn't identify all possible overlapping conditions.&amp;nbsp; Of course this is also dependant on having clients that meet this condition in inventory. If you can think of a better way of doing this please let me know. &lt;/LI&gt;
&lt;LI&gt;Use a simple LDAP query to get all the AD sites specified in the mSSMSSiteBoundaries and mSSMSRoamingBoundaryRange namespaces and create a new Boundary object for each. &lt;/LI&gt;
&lt;LI&gt;Create new Boundary objects for each AD Subnet found (by using another LDAP query to get the subnets) that is associated with an AD Site found in either SMS or AD. &lt;/LI&gt;
&lt;LI&gt;Sort the array of Boundary objects by site code. &lt;/LI&gt;
&lt;LI&gt;Find overlapping boundaries by looking for explicit boundary matches for AD site names or IP Subnets specified in SMS. &lt;/LI&gt;
&lt;LI&gt;Find overlapping boundaries by looking for any overlapping integer IP ranges of which we have for every type of boundary. &lt;/LI&gt;
&lt;LI&gt;Mark any Boundary object found to be overlapping as such. &lt;/LI&gt;
&lt;LI&gt;Dump all boundaries to a log and XML file. &lt;/LI&gt;
&lt;LI&gt;Connect to the client if specified and determine what sites the client falls under. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Things to consider: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Boundary objects are created where they are found.&amp;nbsp; What this means is that it may appear you have duplicate boundary objects.&amp;nbsp; For instance, an AD Site Boundary specified in one SMS site under both the "Roaming Boundaries" and "Site Boundaries" sections will generate at least 5 boundary objects.&amp;nbsp; None of these will appear overlapping but can cause confusion.&amp;nbsp; This occurs because the boundary is found in two places in SMS (one legacy boundary and one roaming boundary), two places in AD (one legacy boundary and one roaming boundary), and at least one additional boundary for any subnets that are linked to the AD Site. &lt;/LI&gt;
&lt;LI&gt;The old SMSBoundaries.exe used a nicely formatted log file to display the output.&amp;nbsp; The SMSBoundaries script uses a nicely formatted xml file and poorly formatted log file.&amp;nbsp; Many people have requested either a better log file or output to a csv file.&amp;nbsp; I'm glad I converted this to vbscript so someone else can do this &lt;SPAN style="FONT-FAMILY: Wingdings"&gt;&lt;/SPAN&gt;.&amp;nbsp; It's on my list of things to do but it's a low priority. If anyone can comment on how to easily convert the XML to a nicely formatted spreadsheet please do (I know Office 2007 has some options for this). &lt;/LI&gt;
&lt;LI&gt;If a client is specified on the command line that information won't be written to the XML, you have to view the log file.&amp;nbsp; This is really only useful if you're troubleshooting a specific client or site. &lt;/LI&gt;
&lt;LI&gt;Verbose logging is helpful if you think you've found an issue with the script. &lt;/LI&gt;
&lt;LI&gt;If you have any SMS Subnets specified in any of the sites in your hierarchy then the script will query the IP information for every client in the hierarchy. In large hierarchies (50k + clients) the script may run for over an hour because of this. &lt;/LI&gt;
&lt;LI&gt;If you have lots of overlapping boundaries the best way to figure out which boundary is overlapping it is to use the log. Just search for the boundary range or subnet that is listed as overlapping in the XML and if you're in the overlapping section of the log it will show you the boundary that it found which overlapped it. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;*This is an example of how to find overlapping boundaries in your environment.&amp;nbsp; If you find any issues with this example or can think of additional functionality which should be added please comment on this blog entry.&amp;nbsp; If any updates to this example are needed I will upload the script changes to this blog entry and update the version number in the title.* &lt;/STRONG&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1919983" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/rslaten/attachment/1919983.ashx" length="84246" type="text/plain" /><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item><item><title>Submitting software inventory records to an SMS 2003 MP using the MP API </title><link>http://blogs.msdn.com/rslaten/archive/2006/07/03/Submitting-software-inventory-records-to-an-SMS-2003-MP-using-the-MP-API-.aspx</link><pubDate>Mon, 03 Jul 2006 20:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:655384</guid><dc:creator>rslaten</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/655384.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=655384</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=655384</wfw:comment><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;There are several supported ways to add data to the SMS database but they typically come from an SMS 2003 advanced client.&amp;nbsp; If you want to add data to an existing client without having to make the agent on the client send it up, or add data to the database for a non-SMS client, then you can use the MP API.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;The &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=58833CD1-6DBB-45BB-BB77-163446068EF6&amp;amp;displaylang=en"&gt;&lt;FONT face=Arial size=2&gt;SMS SDK&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt; contains documentation and some sample code for submitting data via the MP API.&amp;nbsp; There are some other things you'll need to do in order to get the MP API working with SMS 2003 SP1 and above.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;Below is an example of using the MP API to submit&amp;nbsp;software inventory&amp;nbsp;data to a Management Point.&amp;nbsp; This data gets converted from XML to a&amp;nbsp;SIC by the MP, then moved to the site server, and finally loaded into the database.&amp;nbsp; Keep in mind that the&amp;nbsp;software inventory&amp;nbsp;data I'm loading into the database in this example is the minimum so much more can be added.&amp;nbsp; Also, you can create your own GUIDs using &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/html/8d5cedea-8c2b-4918-99db-1a000989f178.asp"&gt;&lt;FONT face=Arial size=2&gt;CoCreateGUID()&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;Here are some tips when developing/testing submitting discovery data using the MP API.&lt;BR&gt;-&amp;nbsp; Enable &lt;A href="http://blogs.msdn.com/rslaten/archive/2006/03/14/SMS_2003_Logging.aspx"&gt;verbose and debug logging&lt;/A&gt; on the SMS 2003 Management Point you're working with.&lt;BR&gt;-&amp;nbsp; Have an SMS 2003 advanced client already submitting data to this MP.&lt;BR&gt;-&amp;nbsp; Turn on &lt;A href="http://blogs.msdn.com/rslaten/archive/2006/03/14/SMS_2003_Logging.aspx"&gt;report archival&lt;/A&gt; on the advanced client so you can see what a properly formatted XML looks like.&lt;BR&gt;-&amp;nbsp; View the following logs in this order: IIS logs (shows IIS handling the message), ccmisapi.log (SMS ISAPI filter), MP_Sinv.log (converts the XML to a SIC), mpfdm.log (moves the&amp;nbsp;SIC from the MP to site server), and sinvproc.log (loads the&amp;nbsp;SIC into the database).&lt;BR&gt;-&amp;nbsp; Make sure you've installed the hotfix from KB917873 onto your SDK.&amp;nbsp; This article is not published as of 07/03/2006 but the hotfix is still available by calling Microsoft support.&lt;BR&gt;-&amp;nbsp; Don't forget to set the Byte Order Mark in your XML attachment.&lt;BR&gt;-&amp;nbsp; Make sure you call SetClientID, which is only usable if you've included the .h/.c files from KB917873 in your project.&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;BR&gt;-&amp;nbsp; If the program fails when running on the MP with http:// in front of the MP Name, try running it without the http:// (this goes through COM instead of IIS).&lt;FONT face=Arial size=2&gt;&lt;BR&gt;-&amp;nbsp; Run the &lt;A href="http://blogs.msdn.com/rslaten/archive/2006/06/28/How_to_submit_discovery_reports_to_an_SMS_2003_Management_Point_using_the_MP_API.aspx"&gt;DDRExample&lt;/A&gt; program first to create a discovery record in the database prior to using this application&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;DIV style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;FONT size=2&gt;&lt;FONT color=#009f00&gt;//MPAPI-SinvExample.cpp : Defines the entry point for the console application.
//Rslaten 07/2006&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "stdafx.h"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "MPAPI-SinvExample.h"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "SmsMsgAPI.h"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "SmsMsgAPI_i.c"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "strsafe.h"
&lt;FONT color=#0000ff&gt;#ifdef&lt;/FONT&gt; _DEBUG
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; new DEBUG_NEW
&lt;FONT color=#0000ff&gt;#endif&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; MAX_BUFFER_LENGTH 0x1000

CWinApp theApp;

&lt;FONT color=#0000ff&gt;using namespace&lt;/FONT&gt; std;

&lt;FONT color=#009f00&gt;//  Macros to perform error handling and make the code cleaner.&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _BEGIN \
    HRESULT __hrRetVal = S_OK; \
    { \
 
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _END \
    } \
    __End: \
 
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _RETVAL __hrRetVal
 
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _CHECKHR(expr) &lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;(FAILED(expr)) { __hrRetVal=expr; &lt;FONT color=#0000ff&gt;goto&lt;/FONT&gt; __End; }

&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; wmain( &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; argc, &lt;FONT color=#0000ff&gt;wchar_t&lt;/FONT&gt; *argv[], &lt;FONT color=#0000ff&gt;wchar_t&lt;/FONT&gt; *envp[] )
{
	&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; nRetCode = 0;

	&lt;FONT color=#009f00&gt;// initialize MFC and print and error on failure&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		&lt;FONT color=#009f00&gt;// TODO: change error code to suit your needs&lt;/FONT&gt;
		_tprintf(_T("Fatal Error: MFC initialization failed\n"));
		nRetCode = 1;
	}
	&lt;FONT color=#0000ff&gt;else&lt;/FONT&gt;
	{
		&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (argc &amp;lt; 2)
		{
			printf("Usage:MPAPI-HinvExample.exe &amp;lt;&lt;/FONT&gt;&lt;A href="http://mpname&gt;/"&gt;&lt;FONT size=2&gt;http://mpname&amp;gt;&lt;/FONT&gt;&lt;/A&gt;&lt;HTTP: mpname&gt;&lt;FONT size=2&gt;\n");
		}
		&lt;FONT color=#0000ff&gt;else&lt;/FONT&gt;
		{
			&lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; WCHAR SINVBody[MAX_BUFFER_LENGTH];
			&lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; WCHAR SINVAttach[MAX_BUFFER_LENGTH];
			ISmsMessaging               *pMessaging = NULL;
			ISmsMessage                 *pRequest = NULL;
			ISmsMessage                 *pReply = NULL;
			ISmsMessage2				*pRequest2 = NULL;
			WCHAR                       *pszRequestMessage = NULL;
			WCHAR                       *pszReplyMessage = NULL;
			WCHAR						*sMPName = NULL;
			WCHAR						*pszTrackingID = NULL;
			LPCWSTR						sClientID = NULL;
			LPCWSTR						sReportID = NULL;
			LPCWSTR						sEndPoint = NULL;

			&lt;FONT color=#009f00&gt;//Set variables&lt;/FONT&gt;
			sReportID = L"{00000000-0000-0000-0000-000000000002}";
			sEndPoint = L"MP_SinvEndpoint";
			sClientID = L"GUID:8081C07C-4674-48E4-A525-5CAD419A4EB3";
			sMPName = argv[1];

			CoInitialize(NULL);

			&lt;FONT color=#009f00&gt;//Build Report Header for Hinv&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVBody,L"&amp;lt;ReportHeader&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVBody,L"&amp;lt;Identification&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVBody,L"&amp;lt;Machine&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVBody,L"&amp;lt;ClientID&amp;gt;GUID:8081C07C-4674-48E4-A525-5CAD419A4EB3&amp;lt;/ClientID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVBody,L"&amp;lt;/Machine&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVBody,L"&amp;lt;/Identification&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVBody,L"&amp;lt;/ReportHeader&amp;gt;");
			&lt;FONT color=#009f00&gt;//Build Message Attachment for Hinv&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;                SINVAttach[0] = 0xFEFF; //Add BOM&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;Report&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;ReportHeader&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;Identification&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;Machine&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;ClientInstalled&amp;gt;1&amp;lt;/ClientInstalled&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;ClientType&amp;gt;1&amp;lt;/ClientType&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;ClientID&amp;gt;GUID:8081C07C-4674-48E4-A525-5CAD419A4EB3&amp;lt;/ClientID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;ClientVersion&amp;gt;1.0&amp;lt;/ClientVersion&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;NetBIOSName&amp;gt;MPAPITestClient&amp;lt;/NetBIOSName&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;CodePage&amp;gt;437&amp;lt;/CodePage&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;SystemDefaultLCID&amp;gt;1033&amp;lt;/SystemDefaultLCID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;/Machine&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;/Identification&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;ReportDetails&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;ReportContent&amp;gt;Inventory\\x0020Data&amp;lt;/ReportContent&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;ReportType&amp;gt;Full&amp;lt;/ReportType&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;Date&amp;gt;20060120124946.000000-360&amp;lt;/Date&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;Version&amp;gt;1.3&amp;lt;/Version&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;Format&amp;gt;1.0&amp;lt;/Format&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;/ReportDetails&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;InventoryAction ActionType=\"Predefined\"&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; wcscat(SINVAttach,L"&amp;lt;InventoryActionID&amp;gt;{00000000-0000-0000-0000-000000000002}&amp;lt;/InventoryActionID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;Description&amp;gt;Software&amp;lt;/Description&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; wcscat(SINVAttach,L"&amp;lt;InventoryActionLastUpdateTime&amp;gt;20050913162140.000000+000&amp;lt;/InventoryActionLastUpdateTime&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;/InventoryAction&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;/ReportHeader&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;ReportBody&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;Instance ParentClass=\"FileSystemFile\" Class=\"FileSystemFile\"");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L" Namespace=\"&lt;/FONT&gt;&lt;A&gt;&lt;FONT size=2&gt;\\\\MPAPITestClient\\ROOT\\ccm\\invagt\\\&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;" Content=\"New\"&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;FileSystemFile&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;CompanyName&amp;gt;Microsoft\\x0020Corporation&amp;lt;/CompanyName&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;FileDescription&amp;gt;Notepad&amp;lt;/FileDescription&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;FileVersion&amp;gt;5.1.2600.2180\\x0020(xpsp_sp2_rtm.040803-2158)&amp;lt;/FileVersion&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;LastWriteDate&amp;gt;20040804060000.000000+***&amp;lt;/LastWriteDate&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;Name&amp;gt;notepad.exe&amp;lt;/Name&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;Path&amp;gt;C:\\\\WINDOWS\\\\system32\\\\&amp;lt;/Path&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;ProductLanguage&amp;gt;1033&amp;lt;/ProductLanguage&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; wcscat(SINVAttach,L"&amp;lt;ProductName&amp;gt;Microsoft&amp;amp;#174;\\x0020Windows&amp;amp;#174;\\x0020Operating\\x0020System&amp;lt;/ProductName&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;ProductVersion&amp;gt;5.1.2600.2180&amp;lt;/ProductVersion&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;Size&amp;gt;69120&amp;lt;/Size&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;/FileSystemFile&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;/Instance&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;/ReportBody&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(SINVAttach,L"&amp;lt;/Report&amp;gt;");
		_BEGIN

			&lt;FONT color=#009f00&gt;//Create root messaging object&lt;/FONT&gt;
			_CHECKHR( ::CoCreateInstance(
                        CLSID_SmsMessaging,
                        NULL,
                        CLSCTX_INPROC,
                        IID_ISmsMessaging,
                        (LPVOID*)&amp;amp;pMessaging) );

			&lt;FONT color=#009f00&gt;//Create message object for request&lt;/FONT&gt;
			_CHECKHR( pMessaging-&amp;gt;CreateMessage(&amp;amp;pRequest) );

			&lt;FONT color=#009f00&gt;//Use the SetClientID method (must have .c/.h files from KB917873)&lt;/FONT&gt;
			_CHECKHR( pRequest-&amp;gt;QueryInterface(IID_ISmsMessage2, (&lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; **) &amp;amp;pRequest2) );
			_CHECKHR( pRequest2-&amp;gt;SetClientID(sClientID) );

			&lt;FONT color=#009f00&gt;//Set Body (Header)&lt;/FONT&gt;
			_CHECKHR( pRequest2-&amp;gt;SetBodyFromString(SINVBody) );

			&lt;FONT color=#009f00&gt;//Get length of attachment&lt;/FONT&gt;
			size_t pcch;
			StringCchLengthW(SINVAttach,MAX_BUFFER_LENGTH,&amp;amp;pcch);
			ULONG uSize = pcch * 2;

			&lt;FONT color=#009f00&gt;//Set Attachment&lt;/FONT&gt;
			_CHECKHR( pRequest2-&amp;gt;SetAttachmentFromBuffer(
                        sReportID,
                        (&lt;FONT color=#0000ff&gt;const&lt;/FONT&gt; BYTE*)SINVAttach,
                        uSize) );
			
			&lt;FONT color=#009f00&gt;//Set EndPoint&lt;/FONT&gt;
			_CHECKHR( pRequest2-&amp;gt;SetTargetEndpoint(sEndPoint) );

			&lt;FONT color=#009f00&gt;//Post Message&lt;/FONT&gt;
			_CHECKHR( pMessaging-&amp;gt;Post(sMPName, pRequest2, &amp;amp;pszTrackingID) );

		_END

			printf("\n\n%s%X", "Return Code=", __hrRetVal);

			&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;(pszTrackingID)
			{
				::CoTaskMemFree(pszTrackingID);
			}
			&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; S_OK;

			pRequest2-&amp;gt;Release();
		}
	}
	CoUninitialize();
	&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; nRetCode;
}&lt;/FONT&gt;
&lt;/DIV&gt;&lt;/PRE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=655384" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item><item><title>Submitting hardware inventory records to an SMS 2003 MP using the MP API </title><link>http://blogs.msdn.com/rslaten/archive/2006/06/29/Submitting-hardware-inventory-records-to-an-SMS-2003-MP-using-the-MP-API-.aspx</link><pubDate>Fri, 30 Jun 2006 01:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:651372</guid><dc:creator>rslaten</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/651372.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=651372</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=651372</wfw:comment><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;There are several supported ways to add data to the SMS database but they typically come from an SMS 2003 advanced client.&amp;nbsp; If you want to add data to an existing client without having to make the agent on the client send it up, or add data to the database for a non-SMS client, then you can use the MP API.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;The &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=58833CD1-6DBB-45BB-BB77-163446068EF6&amp;amp;displaylang=en"&gt;&lt;FONT face=Arial size=2&gt;SMS SDK&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt; contains documentation and some sample code for submitting data via the MP API.&amp;nbsp; There are some other things you'll need to do in order to get the MP API working with SMS 2003 SP1 and above.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;Below is an example of using the MP API to submit&amp;nbsp;hardware inventory&amp;nbsp;data to a Management Point.&amp;nbsp; This data gets converted from XML to a&amp;nbsp;MIF by the MP, then moved to the site server, and finally loaded into the database.&amp;nbsp; Keep in mind that the&amp;nbsp;hardware inventory&amp;nbsp;data I'm loading into the database in this example is the minimum so much more can be added.&amp;nbsp; Also, you can create your own GUIDs using &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/html/8d5cedea-8c2b-4918-99db-1a000989f178.asp"&gt;&lt;FONT face=Arial size=2&gt;CoCreateGUID()&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;Here are some tips when developing/testing submitting discovery data using the MP API.&lt;BR&gt;-&amp;nbsp; Enable &lt;A href="http://blogs.msdn.com/rslaten/archive/2006/03/14/SMS_2003_Logging.aspx"&gt;verbose and debug logging&lt;/A&gt; on the SMS 2003 Management Point you're working with.&lt;BR&gt;-&amp;nbsp; Have an SMS 2003 advanced client already submitting data to this MP.&lt;BR&gt;-&amp;nbsp; Turn on &lt;A href="http://blogs.msdn.com/rslaten/archive/2006/03/14/SMS_2003_Logging.aspx"&gt;report archival&lt;/A&gt; on the advanced client so you can see what a properly formatted XML looks like.&lt;BR&gt;-&amp;nbsp; View the following logs in this order: IIS logs (shows IIS handling the message), ccmisapi.log (SMS ISAPI filter), MP_Hinv.log (converts the XML to a MIF), mpfdm.log (moves the&amp;nbsp;MIF from the MP to site server), and dataldr.log (loads the&amp;nbsp;MIF into the database).&lt;BR&gt;-&amp;nbsp; Make sure you've installed the hotfix from KB917873 onto your SDK.&amp;nbsp; This article is not published as of 06/29/2006 but the hotfix is still available by calling Microsoft support.&lt;BR&gt;-&amp;nbsp; Don't forget to set the Byte Order Mark in your XML attachment.&lt;BR&gt;-&amp;nbsp; Make sure you call SetClientID, which is only usable if you've included the .h/.c files from KB917873 in your project.&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;BR&gt;-&amp;nbsp; If the program fails when running on the MP with http:// in front of the MP Name, try running it without the http:// (this goes through COM instead of IIS).&lt;FONT face=Arial size=2&gt;&lt;BR&gt;-&amp;nbsp; Run the &lt;A href="http://blogs.msdn.com/rslaten/archive/2006/06/28/How_to_submit_discovery_reports_to_an_SMS_2003_Management_Point_using_the_MP_API.aspx"&gt;DDRExample&lt;/A&gt; program first to create a discovery record in the database prior to using this application&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;DIV style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;FONT size=2&gt;&lt;FONT color=#009f00&gt;// MPAPI-HinvExample.cpp : Defines the entry point for the console application.
// Rslaten 06/2006&lt;/FONT&gt;&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "stdafx.h"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "MPAPI-HinvExample.h"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "SmsMsgAPI.h"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "SmsMsgAPI_i.c"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "strsafe.h"

&lt;FONT color=#0000ff&gt;#ifdef&lt;/FONT&gt; _DEBUG
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; new DEBUG_NEW
&lt;FONT color=#0000ff&gt;#endif&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; MAX_BUFFER_LENGTH 0x1000

CWinApp theApp;

&lt;FONT color=#0000ff&gt;using namespace&lt;/FONT&gt; std;

&lt;FONT color=#009f00&gt;//  Macros to perform error handling and make the code cleaner.&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _BEGIN \
    HRESULT __hrRetVal = S_OK; \
    { \
 
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _END \
    } \
    __End: \
 
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _RETVAL __hrRetVal
 
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _CHECKHR(expr) &lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;(FAILED(expr)) { __hrRetVal=expr; &lt;FONT color=#0000ff&gt;goto&lt;/FONT&gt; __End; }

&lt;FONT color=#009f00&gt;//Main&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; wmain( &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; argc, &lt;FONT color=#0000ff&gt;wchar_t&lt;/FONT&gt; *argv[], &lt;FONT color=#0000ff&gt;wchar_t&lt;/FONT&gt; *envp[] )
{
	&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; nRetCode = 0;

	&lt;FONT color=#009f00&gt;// initialize MFC and print and error on failure&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;if &lt;/FONT&gt;(!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		&lt;FONT color=#009f00&gt;// TODO: change error code to suit your needs&lt;/FONT&gt;
		_tprintf(_T("Fatal Error: MFC initialization failed\n"));
		nRetCode = 1;
	}
	&lt;FONT color=#0000ff&gt;else&lt;/FONT&gt;
	{
		&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (argc &amp;lt; 3)
		{
			printf("Usage:MPAPI-HinvExample.exe &amp;lt;&lt;/FONT&gt;&lt;A href="http://mpname/"&gt;&lt;FONT size=2&gt;http://mpname&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;&amp;gt; &amp;lt;sitecode&amp;gt;\n");
		}
		&lt;FONT color=#0000ff&gt;else&lt;/FONT&gt;
		{
			&lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; WCHAR HINVBody[MAX_BUFFER_LENGTH];
			&lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; WCHAR HINVAttach[MAX_BUFFER_LENGTH];
			ISmsMessaging               *pMessaging = NULL;
                   ISmsMessage                 *pRequest = NULL;
                   ISmsMessage                 *pReply = NULL;
			ISmsMessage2				*pRequest2 = NULL;
                   WCHAR                       *pszRequestMessage = NULL;
                   WCHAR                       *pszReplyMessage = NULL;
			WCHAR						*sMPName = NULL;
			WCHAR						*sSiteCode = NULL;
			WCHAR						*pszTrackingID = NULL;
			LPCWSTR						sClientID = NULL;
			LPCWSTR						sReportID = NULL;
			LPCWSTR						sEndPoint = NULL;

			&lt;FONT color=#009f00&gt;//Set variables&lt;/FONT&gt;
			sReportID = L"{00000000-0000-0000-0000-000000000001}";
			sEndPoint = L"MP_HinvEndpoint";
			sClientID = L"GUID:8081C07C-4674-48E4-A525-5CAD419A4EB3";
			sMPName = argv[1];
			sSiteCode = argv[2]; &lt;FONT color=#009f00&gt;//Not used&lt;/FONT&gt;

			CoInitialize(NULL);

&amp;nbsp;&amp;nbsp;&amp;nbsp;                &lt;FONT color=#009f00&gt;//Build Report Header for Hinv&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;                &amp;nbsp;wcscat(HINVBody,L"&amp;lt;ReportHeader&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVBody,L"&amp;lt;Identification&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVBody,L"&amp;lt;Machine&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVBody,L"&amp;lt;ClientID&amp;gt;GUID:8081C07C-4674-48E4-A525-5CAD419A4EB3&amp;lt;/ClientID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVBody,L"&amp;lt;/Machine&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVBody,L"&amp;lt;/Identification&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVBody,L"&amp;lt;/ReportHeader&amp;gt;");                 

                   &lt;FONT color=#009f00&gt;//Build Message Attachment for Hinv&lt;/FONT&gt;&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                HINVAttach[0] = 0xFEFF; &lt;FONT color=#009f00&gt;//Add BOM&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;Report&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;ReportHeader&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;Identification&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;Machine&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;ClientInstalled&amp;gt;1&amp;lt;/ClientInstalled&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;ClientType&amp;gt;1&amp;lt;/ClientType&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;ClientID&amp;gt;GUID:8081C07C-4674-48E4-A525-5CAD419A4EB3&amp;lt;/ClientID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;ClientVersion&amp;gt;1.0&amp;lt;/ClientVersion&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;NetBIOSName&amp;gt;MPAPITestClient&amp;lt;/NetBIOSName&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;CodePage&amp;gt;437&amp;lt;/CodePage&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;SystemDefaultLCID&amp;gt;1033&amp;lt;/SystemDefaultLCID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;/Machine&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;/Identification&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;ReportDetails&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;ReportContent&amp;gt;Inventory\\x0020Data&amp;lt;/ReportContent&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;ReportType&amp;gt;Full&amp;lt;/ReportType&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;Date&amp;gt;20060120124946.000000-360&amp;lt;/Date&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;Version&amp;gt;1.3&amp;lt;/Version&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;Format&amp;gt;1.0&amp;lt;/Format&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;/ReportDetails&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;InventoryAction ActionType=\"Predefined\"&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;InventoryActionID&amp;gt;{00000000-0000-0000-0000-000000000001}&amp;lt;/InventoryActionID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;Description&amp;gt;Hardware&amp;lt;/Description&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;InventoryActionLastUpdateTime&amp;gt;20050913162140.000000+000&amp;lt;/InventoryActionLastUpdateTime&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;/InventoryAction&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;/ReportHeader&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;ReportBody&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;Instance ParentClass=\"CCM_System\" Class=\"CCM_System\" Namespace=\"&lt;/FONT&gt;&lt;A&gt;&lt;FONT size=2&gt;\\\\MPAPITestClient&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"//root//ccm//invagt/" Content=\"New\"&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;CCM_System&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;Domain&amp;gt;MPAPITestDOM.com&amp;lt;/Domain&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;LocalDateTime&amp;gt;20060120124932.664000-360&amp;lt;/LocalDateTime&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;Name&amp;gt;MPAPITestClient&amp;lt;/Name&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;SMSID&amp;gt;GUID:8081C07C-4674-48E4-A525-5CAD419A4EB3&amp;lt;/SMSID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;SystemRole&amp;gt;Workstation&amp;lt;/SystemRole&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;SystemType&amp;gt;X86-based\\x0020PC&amp;lt;/SystemType&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;/CCM_System&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;/Instance&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;/ReportBody&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;                wcscat(HINVAttach,L"&amp;lt;/Report&amp;gt;");
		_BEGIN

                   &lt;FONT color=#009f00&gt;//Create root messaging object&lt;/FONT&gt;
                   _CHECKHR( ::CoCreateInstance(
                        CLSID_SmsMessaging,
                        NULL,
                        CLSCTX_INPROC,
                        IID_ISmsMessaging,
                        (LPVOID*)&amp;amp;pMessaging) );

                   &lt;FONT color=#009f00&gt;//Create message object for request&lt;/FONT&gt;
                   _CHECKHR( pMessaging-&amp;gt;CreateMessage(&amp;amp;pRequest) );

			&lt;FONT color=#009f00&gt;//Use the SetClientID method (must have .c/.h files from KB917873)&lt;/FONT&gt;
			_CHECKHR( pRequest-&amp;gt;QueryInterface(IID_ISmsMessage2, (&lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; **) &amp;amp;pRequest2) );
			_CHECKHR( pRequest2-&amp;gt;SetClientID(sClientID) );

			&lt;FONT color=#009f00&gt;//Set Body (Header)&lt;/FONT&gt;
			_CHECKHR( pRequest2-&amp;gt;SetBodyFromString(HINVBody) );

			&lt;FONT color=#009f00&gt;//Get length of attachment&lt;/FONT&gt;
			size_t pcch;
			StringCchLengthW(HINVAttach,MAX_BUFFER_LENGTH,&amp;amp;pcch);
			ULONG uSize = pcch * 2;

			&lt;FONT color=#009f00&gt;//Set Attachment&lt;/FONT&gt;
			_CHECKHR( pRequest2-&amp;gt;SetAttachmentFromBuffer(
                        sReportID,
                        (&lt;FONT color=#0000ff&gt;const&lt;/FONT&gt; BYTE*)HINVAttach,
                        uSize) );
			
			&lt;FONT color=#009f00&gt;//Set EndPoint&lt;/FONT&gt;
			_CHECKHR( pRequest2-&amp;gt;SetTargetEndpoint(sEndPoint) );

			&lt;FONT color=#009f00&gt;//Post Message&lt;/FONT&gt;
			_CHECKHR( pMessaging-&amp;gt;Post(sMPName, pRequest2, &amp;amp;pszTrackingID) );

		_END

			printf("\n\n%s%X", "Return Code=", __hrRetVal);

			&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;(pszTrackingID)
			{
				::CoTaskMemFree(pszTrackingID);
			}
			&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; S_OK;

			pRequest2-&amp;gt;Release();

		}
	}
	CoUninitialize();
	&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; nRetCode;
}&lt;/FONT&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=651372" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item><item><title>Submitting discovery records to an SMS 2003 MP using the MP API</title><link>http://blogs.msdn.com/rslaten/archive/2006/06/28/How-to-submit-discovery-reports-to-an-SMS-2003-Management-Point-using-the-MP-API.aspx</link><pubDate>Wed, 28 Jun 2006 22:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:649989</guid><dc:creator>rslaten</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/649989.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=649989</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=649989</wfw:comment><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;There are several supported ways to add data to the SMS database but they typically come from an SMS 2003 advanced client.&amp;nbsp; If you want to add data to an existing client without having to make the agent on the client send it up, or add data to the database for a non-SMS client, then you can use the MP API.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;The &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=58833CD1-6DBB-45BB-BB77-163446068EF6&amp;amp;displaylang=en"&gt;&lt;FONT face=Arial size=2&gt;SMS SDK&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt; contains documentation and some sample code for submitting data via the MP API.&amp;nbsp; There are some other things you'll need to do in order to get the MP API working with SMS 2003 SP1 and above.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;Below is an example of using the MP API to submit discovery data to a Management Point.&amp;nbsp; This data gets converted from XML to a DDR by the MP, then moved to the site server, and finally loaded into the database.&amp;nbsp; Keep in mind that the discovery data I'm loading into the database in this example is the minimum so much more can be added.&amp;nbsp; Also, you can create your own GUIDs using &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/html/8d5cedea-8c2b-4918-99db-1a000989f178.asp"&gt;&lt;FONT face=Arial size=2&gt;CoCreateGUID()&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;Here are some tips when developing/testing submitting discovery data using the MP API.&lt;BR&gt;-&amp;nbsp; Enable &lt;A href="http://blogs.msdn.com/rslaten/archive/2006/03/14/SMS_2003_Logging.aspx"&gt;verbose and debug logging&lt;/A&gt; on the SMS 2003 Management Point you're working with.&lt;BR&gt;-&amp;nbsp; Have an SMS 2003 advanced client already submitting data to this MP.&lt;BR&gt;-&amp;nbsp; Turn on &lt;A href="http://blogs.msdn.com/rslaten/archive/2006/03/14/SMS_2003_Logging.aspx"&gt;report archival&lt;/A&gt; on the advanced client so you can see what a properly formatted XML looks like.&lt;BR&gt;-&amp;nbsp; View the following logs in this order: IIS logs (shows IIS handling the message), ccmisapi.log (SMS ISAPI filter), MP_Ddr.log (converts the XML to a DDR), mpfdm.log (moves the DDR from the MP to site server), and ddm.log (loads the DDR into the database).&lt;BR&gt;-&amp;nbsp; Make sure you've installed the hotfix from KB917873 onto your SDK.&amp;nbsp; This article is not published as of 06/28/2006 but the hotfix is still available by calling Microsoft support.&lt;BR&gt;-&amp;nbsp; Don't forget to set the Byte Order Mark in your XML attachment.&lt;BR&gt;-&amp;nbsp; Make sure you call SetClientID, which is only usable if you've included the .h/.c files from KB917873 in your project.&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;BR&gt;-&amp;nbsp; If the program fails when running on the MP with http:// in front of the MP Name, try running it without the http:// (this goes through COM instead of IIS).&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;DIV style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;FONT color=#009f00&gt;// DDRExample.cpp : Defines the entry point for the console application.
// Example of how to submit discovery data using the MP API
// This is a standard C++ Win32 console application created
// using the wizard in Visual Studio and adding MFC support
// Rslaten 06/2006&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "stdafx.h"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "DDRExample.h"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "SmsMsgAPI.h"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "SmsMsgAPI_i.c"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "strsafe.h"

&lt;FONT color=#0000ff&gt;#ifdef&lt;/FONT&gt; _DEBUG
&lt;FONT color=#0000ff&gt;#define new&lt;/FONT&gt; DEBUG_NEW
&lt;FONT color=#0000ff&gt;#endif&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; MAX_BUFFER_LENGTH 0x1000

CWinApp theApp;

&lt;FONT color=#0000ff&gt;using namespace&lt;/FONT&gt; std;

&lt;FONT color=#009f00&gt;//  Macros to perform error handling and make the code cleaner.&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _BEGIN \
    HRESULT __hrRetVal = S_OK; \
    { \
 
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _END \
    } \
    __End: \
 
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _RETVAL __hrRetVal
 
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _CHECKHR(expr) &lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;(FAILED(expr)) { __hrRetVal=expr; &lt;FONT color=#0000ff&gt;goto&lt;/FONT&gt; __End; }

&lt;FONT color=#009f00&gt;//Main&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; wmain( &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; argc, &lt;FONT color=#0000ff&gt;wchar_t&lt;/FONT&gt; *argv[], &lt;FONT color=#0000ff&gt;wchar_t&lt;/FONT&gt; *envp[] )
{
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int&lt;/FONT&gt; nRetCode = 0;

	&lt;FONT color=#009f00&gt;// initialize MFC and print and error on failure&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		_tprintf(_T("Fatal Error: MFC initialization failed\n"));
		nRetCode = 1;
	}
	&lt;FONT color=#0000ff&gt;else&lt;/FONT&gt;
	{
&lt;PRE dir=ltr&gt;		&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (argc &amp;lt; 3)
		{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf("Usage:DDRExample.exe &amp;lt;&lt;A href="http://mpname/"&gt;&lt;FONT color=#000000&gt;http://mpname&lt;/FONT&gt;&lt;/A&gt;&amp;gt; &amp;lt;sitecode&amp;gt;&lt;HTTP: mpname&gt; &lt;SITECODE&gt;\n");
		}
		&lt;FONT color=#0000ff&gt;else&lt;/FONT&gt;
		{
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;static&lt;/FONT&gt; WCHAR DDRBody[MAX_BUFFER_LENGTH];
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;static&lt;/FONT&gt; WCHAR DDRAttach[MAX_BUFFER_LENGTH];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ISmsMessaging *pMessaging = NULL;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ISmsMessage *pRequest = NULL;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ISmsMessage *pReply = NULL;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ISmsMessage2 *pRequest2 = NULL;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WCHAR *pszRequestMessage = NULL;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WCHAR *pszReplyMessage = NULL;&lt;/PRE&gt;&lt;PRE dir=ltr&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WCHAR *sMPName = NULL;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WCHAR *sSiteCode = NULL;&lt;/PRE&gt;&lt;PRE dir=ltr&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LPCWSTR sClientID = NULL;&lt;/PRE&gt;&lt;PRE dir=ltr&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LPCWSTR sReportID = NULL;&lt;/PRE&gt;&lt;PRE dir=ltr&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LPCWSTR sEndPoint = NULL;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WCHAR *pszTrackingID = NULL;
			
&lt;FONT color=#009f00&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Set variables&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sReportID = L"{00000000-0000-0000-0000-000000000003}";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sEndPoint = L"MP_DdrEndpoint";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sClientID = L"GUID:8081C07C-4674-48E4-A525-5CAD419A4EB3";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sMPName = argv[1];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sSiteCode = argv[2];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;PRE dir=ltr&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CoInitialize(NULL);

&lt;FONT color=#009f00&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Build Report Header for DDR&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRBody,L"&amp;lt;ReportHeader&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRBody,L"&amp;lt;Identification&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRBody,L"&amp;lt;Machine&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRBody,L"&amp;lt;ClientID&amp;gt;GUID:8081C07C-4674-48E4-A525-5CAD419A4EB3&amp;lt;/ClientID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRBody,L"&amp;lt;/Machine&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRBody,L"&amp;lt;/Identification&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRBody,L"&amp;lt;/ReportHeader&amp;gt;");&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;PRE&gt;   &lt;FONT color=#009f00&gt;//Build Message Attachment for DDR&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;DDRAttach[0] = 0xFEFF; &lt;FONT color=#009f00&gt;//Add BOM (This is very important)&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;?xml version='1.0' encoding='UTF-16'?&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;Report&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;ReportHeader&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;Identification&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;Machine&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;ClientInstalled&amp;gt;1&amp;lt;/ClientInstalled&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;ClientType&amp;gt;1&amp;lt;/ClientType&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;ClientID&amp;gt;GUID:8081C07C-4674-48E4-A525-5CAD419A4EB3&amp;lt;/ClientID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;ClientVersion&amp;gt;1.0&amp;lt;/ClientVersion&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;NetBIOSName&amp;gt;MPAPITestClient&amp;lt;/NetBIOSName&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;CodePage&amp;gt;437&amp;lt;/CodePage&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;SystemDefaultLCID&amp;gt;1033&amp;lt;/SystemDefaultLCID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;/Machine&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;/Identification&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;ReportDetails&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;ReportContent&amp;gt;Inventory\\x0020Data&amp;lt;/ReportContent&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;ReportType&amp;gt;Full&amp;lt;/ReportType&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;Date&amp;gt;20060123125307.000000+000&amp;lt;/Date&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;Version&amp;gt;6.0&amp;lt;/Version&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;Format&amp;gt;1.0&amp;lt;/Format&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;/ReportDetails&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;InventoryAction ActionType=\"Predefined\"&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;InventoryActionID&amp;gt;{00000000-0000-0000-0000-000000000003}&amp;lt;/InventoryActionID&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;Description&amp;gt;Discovery&amp;lt;/Description&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;InventoryActionLastUpdateTime&amp;gt;20050913162047.000000+000&amp;lt;/InventoryActionLastUpdateTime&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;/InventoryAction&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;/ReportHeader&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;ReportBody&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;Instance ParentClass=\"SMS_Authority\" Class=\"SMS_Authority\" Namespace=");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"\"&lt;A&gt;\\\\MPAPITestClient\\ROOT\\ccm\&lt;/A&gt;" Content=\"New\"&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;SMS_Authority&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;Name&amp;gt;SMS:");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach, sSiteCode);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach, L"&amp;lt;/Name&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;/SMS_Authority&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;/Instance&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;/ReportBody&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wcscat(DDRAttach,L"&amp;lt;/Report&amp;gt;");&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;
		_BEGIN

                   &lt;FONT color=#009f00&gt;//Create root messaging object&lt;/FONT&gt;
                   _CHECKHR( ::CoCreateInstance(
                        CLSID_SmsMessaging,
                        NULL,
                        CLSCTX_INPROC,
                        IID_ISmsMessaging,
                        (LPVOID*)&amp;amp;pMessaging) );

                   &lt;FONT color=#009f00&gt;//Create message object for request&lt;/FONT&gt;
                   _CHECKHR( pMessaging-&amp;gt;CreateMessage(&amp;amp;pRequest) );

			&lt;FONT color=#009f00&gt;//Use the SetClientID method (must have .c/.h files from KB917873)&lt;/FONT&gt;
			_CHECKHR( pRequest-&amp;gt;QueryInterface(IID_ISmsMessage2, (&lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; **) &amp;amp;pRequest2) );
			_CHECKHR( pRequest2-&amp;gt;SetClientID(sClientID) );

			&lt;FONT color=#009f00&gt;//Set Body (Header)&lt;/FONT&gt;
			_CHECKHR( pRequest2-&amp;gt;SetBodyFromString(DDRBody) );

			&lt;FONT color=#009f00&gt;//Get length of attachment&lt;/FONT&gt;
			size_t pcch;
			StringCchLengthW(DDRAttach,MAX_BUFFER_LENGTH,&amp;amp;pcch);
			ULONG uSize = pcch * 2;

			&lt;FONT color=#009f00&gt;//Set Attachment&lt;/FONT&gt;
			_CHECKHR( pRequest2-&amp;gt;SetAttachmentFromBuffer(
                        sReportID,
                        (&lt;FONT color=#0000ff&gt;const&lt;/FONT&gt; BYTE*)DDRAttach,
                        uSize) );
			
			&lt;FONT color=#009f00&gt;//Set EndPoint&lt;/FONT&gt;
			_CHECKHR( pRequest2-&amp;gt;SetTargetEndpoint(sEndPoint) );

			&lt;FONT color=#009f00&gt;//Post Message&lt;/FONT&gt;
			_CHECKHR( pMessaging-&amp;gt;Post(sMPName, pRequest2, &amp;amp;pszTrackingID) );

		_END

			printf("\n\n%s%X", "Return Code=", __hrRetVal);

			&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;(pszTrackingID)
			{
				::CoTaskMemFree(pszTrackingID);
			}
			&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; S_OK;

			pRequest2-&amp;gt;Release();
		}
	}

	CoUninitialize();
	&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; nRetCode;
}&lt;FONT size=1&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=649989" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item><item><title>Creating a CCR through WMI</title><link>http://blogs.msdn.com/rslaten/archive/2006/06/14/Creating-a-CCR-through-WMI.aspx</link><pubDate>Thu, 15 Jun 2006 00:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:631435</guid><dc:creator>rslaten</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/631435.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=631435</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=631435</wfw:comment><description>&lt;PRE&gt;&lt;FONT face=Arial&gt;
&lt;PRE&gt;&lt;FONT face=Arial size=2&gt;I was recently troubleshooting a problem with the Install Client wizard in the admin console which will be documented in the KB shortly.&amp;nbsp; To workaround &lt;/FONT&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;FONT face=Arial size=2&gt;the issue I created a script that uses the same WMI methods (CreateCCRs and CreateCCR) that this wizard uses.&amp;nbsp; This exact script may not be applicable to &lt;/FONT&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;FONT face=Arial size=2&gt;everyone but it does demonstrate how to use the CreateCCR and CreateCCRs methods.&amp;nbsp; &lt;/FONT&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;FONT face=Arial&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;FONT face=Arial size=2&gt;To install the script simply execute the vbs on your SMS Admin console box, then launch the script through the admin console - queries node.&lt;/FONT&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;FONT face=Arial&gt;&lt;DIV style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;FONT size=2&gt;&lt;FONT color=#009f00&gt;&lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;

'Rslaten 06/01/2006
'VBScript to add a new node to the SMS Admin Console\Queries\&lt;QUERY&gt; called SMS_Tools\Install Clients
'Once ran from the Admin Console it uses the CreateCCRs WMI method on the SMS_Query instance to create CCRs
'Update:  This VBScript now adds a menu to push a CCR for a single client (result of the query)
'This uses the SMS_Collection::CreateCCR method with the same parameters
'The CCRs created have the following parameters:

'SMS_Query::CreateCCRs method parameters
'PushOnlyAssignedClients = FALSE
'ClientType = 1
'Forced = TRUE
'PushEvenIfDC = FALSE
'InformationOnly = FALSE

'SMS_Collection::CreateCCR method parameters
'ResourceID = &lt;RESID passed from admin console&gt;
'PushOnlyAssignedClients = FALSE
'ClientType = 1
'Forced = TRUE
'PushEvenIfDC = FALSE
'InformationOnly = FALSE&lt;/FONT&gt;

Main

&lt;FONT color=#0000ff&gt;Sub&lt;/FONT&gt; Main

	&lt;FONT color=#0000ff&gt;On Error Resume Next&lt;/FONT&gt;
	
	&lt;FONT color=#009f00&gt;'Check to see if any parameters were passed&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; WScript.Arguments.Count = 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
		&lt;FONT color=#009f00&gt;'This is being run by a user so create regkeys and copy script to admin console directory&lt;/FONT&gt;
		InstallScript
		WScript.Quit
	&lt;FONT color=#0000ff&gt;Else&lt;/FONT&gt;
		&lt;FONT color=#009f00&gt;'This is being run from the admin console so continue with CCR creation&lt;/FONT&gt;
		CreateCCRs
	&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;End Sub&lt;/FONT&gt;

&lt;FONT color=#009f00&gt;'Install routine (only runs if no parameters are passed to script)&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;Sub&lt;/FONT&gt; InstallScript

	&lt;FONT color=#0000ff&gt;On Error Resume Next&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt; oShell, sUIPath, oFso, sCurrentDirectory
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; oShell = CreateObject("WScript.Shell")
	&lt;FONT color=#0000ff&gt;Set &lt;/FONT&gt;oFSO = CreateObject("Scripting.FileSystemObject")
	
	&lt;FONT color=#009f00&gt;'Get directory of SMS Admin Console&lt;/FONT&gt;
	sUIPath = oShell.RegRead("HKLM\SOFTWARE\Microsoft\SMS\Setup\UI Installation Directory")
	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
		WScript.Echo "Failed to get Admin Console Installation Directory from registry"
		WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
		WScript.Quit
	&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
	
	&lt;FONT color=#009f00&gt;'Get current directory&lt;/FONT&gt;
	sCurrentDirectory = oShell.CurrentDirectory
	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
		WScript.Echo "Failed to get current directory"
		WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
		WScript.Quit
	&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;	
	
	&lt;FONT color=#009f00&gt;'Create registry key for MMC snapin&lt;/FONT&gt;
	oShell.RegWrite "HKLM\SOFTWARE\Microsoft\MMC\NodeTypes\{58105356-2B9C-11D1-B0D5-00C04FBBD480}" _
	&amp;amp; "\Extensions\SMS_Tools\ForceInstallClient\CommandLine", "wscript.exe " &amp;amp; sUIPath &amp;amp; "\ClientInstall.vbs " _
	&amp;amp; "##SUB:__SERVER## ##SUB:__NAMESPACE## ##SUB:QueryID##"
	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
		WScript.Echo "Failed to create MMC snap-in regkey and CommandLine value"
		WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
		WScript.Quit
	&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
	
	oShell.RegWrite "HKLM\SOFTWARE\Microsoft\MMC\NodeTypes\{58105356-2B9C-11D1-B0D5-00C04FBBD480}" _
	&amp;amp; "\Extensions\SMS_Tools\ForceInstallClient\Description", "Install Client"
	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
		WScript.Echo "Failed to create Description regvalue"
		WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
		WScript.Quit
	&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
	
	oShell.RegWrite "HKLM\SOFTWARE\Microsoft\MMC\NodeTypes\{58105356-2B9C-11D1-B0D5-00C04FBBD480}" _
	&amp;amp; "\Extensions\SMS_Tools\ForceInstallClient\Name", "Install Clients"
	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
		WScript.Echo "Failed to create Name regvalue"
		WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
		WScript.Quit
	&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
	
	oShell.RegWrite "HKLM\SOFTWARE\Microsoft\MMC\NodeTypes\{4D26C0D4-A8A8-11D1-9BD9-00C04FBBD480}" _
	&amp;amp; "\Extensions\SMS_Tools\ForceInstallClient\CommandLine", "wscript.exe " &amp;amp; sUIPath _
	&amp;amp; "\ClientInstall.vbs ##SUB:__SERVER## ##SUB:__NAMESPACE## ##SUB:ResourceID##"
	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
		WScript.Echo "Failed to create MMC snap-in regkey and CommandLine value"
		WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
		WScript.Quit
	&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
	
	oShell.RegWrite "HKLM\SOFTWARE\Microsoft\MMC\NodeTypes\{4D26C0D4-A8A8-11D1-9BD9-00C04FBBD480}" _
	&amp;amp; "\Extensions\SMS_Tools\ForceInstallClient\Description", "Install Client"
	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
		WScript.Echo "Failed to create Description regvalue"
		WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
		WScript.Quit
	&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
	
	oShell.RegWrite "HKLM\SOFTWARE\Microsoft\MMC\NodeTypes\{4D26C0D4-A8A8-11D1-9BD9-00C04FBBD480}" _
	&amp;amp; "\Extensions\SMS_Tools\ForceInstallClient\Name", "Install Client"
	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
		WScript.Echo "Failed to create Name regvalue"
		WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
		WScript.Quit
	&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
	
	&lt;FONT color=#009f00&gt;'Copy this script to the SMS Admin Console directory&lt;/FONT&gt;
	oFSO.CopyFile WScript.ScriptFullName, sUIPath &amp;amp; "\ClientInstall.vbs"
	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
		WScript.Echo "Failed to copy " &amp;amp; sCurrentDirectory &amp;amp; "\ClientInstall.vbs to " &amp;amp; sUIPath &amp;amp; "\"
		WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
		WScript.Quit
	&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
	
	WScript.Echo "Successfully Installed ClientInstall.vbs onto your SMS Admin Console!"
	
	&lt;FONT color=#009f00&gt;'Clean up objects&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; oFSO = &lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; oShell = &lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;
	
&lt;FONT color=#0000ff&gt;End Sub&lt;/FONT&gt;

&lt;FONT color=#009f00&gt;'Create CCR routine (only runs if being ran from admin console)&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;Sub&lt;/FONT&gt; CreateCCRs

	&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;On Error Resume Next
	Dim&lt;/FONT&gt; oWMI, sSMSNamespace, sSMSServer, sQueryID, sResourceID, sTempArg
	
	&lt;FONT color=#009f00&gt;'Go through parameters passed by script&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; objArgs = WScript.Arguments
	sTempArg = objArgs(2)

	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; IsNumeric(sTempArg) = &lt;FONT color=#0000ff&gt;FALSE Then&lt;/FONT&gt;
		sSMSServer = objArgs(0)
		sSMSNamespace = objArgs(1)
		sQueryID = objArgs(2)
		
		&lt;FONT color=#009f00&gt;'Connect to WMI&lt;/FONT&gt;
		&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; oWMI = GetObject("winMgmts:\\" &amp;amp; sSMSServer &amp;amp; "\" &amp;amp; sSMSNamespace &amp;amp; ":SMS_Query.QueryID='" _
		&amp;amp; sQueryID &amp;amp; "'")
		&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
			WScript.Echo "Failed to connect to WMI on " &amp;amp; sSMSServer
			WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
			WScript.Quit
		&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
		
		&lt;FONT color=#009f00&gt;'Run CreateCCRs Method&lt;/FONT&gt;
		oWMI.CreateCCRs &lt;FONT color=#0000ff&gt;FALSE&lt;/FONT&gt;, 1, &lt;FONT color=#0000ff&gt;TRUE&lt;/FONT&gt;, &lt;FONT color=#0000ff&gt;FALSE&lt;/FONT&gt;, &lt;FONT color=#0000ff&gt;FALSE&lt;/FONT&gt;
		&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
			WScript.Echo "Failed to run CreateCCRs method on " &amp;amp; sSMSServer
			WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
			WScript.Quit
		&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
		
		WScript.Echo "Client Install Request(s) Sent Successfully!"
	&lt;FONT color=#0000ff&gt;Else&lt;/FONT&gt;
		sSMSServer = objArgs(0)
		sSMSNamespace = objArgs(1)
		sResourceID = objArgs(2)
		
		&lt;FONT color=#009f00&gt;'Check to see if we fail to get the 3rd parameter (if so this is an issue with the SMS Admin Console)&lt;/FONT&gt;
		&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;or&lt;/FONT&gt; sResourceID = "" &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
			sResourceID = InputBox("Please Enter the Resource ID of this Client", "Client Install")
			&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; sResourceID = "" &lt;FONT color=#0000ff&gt;or&lt;/FONT&gt; IsNumeric(sResourceID) = &lt;FONT color=#0000ff&gt;FALSE Then&lt;/FONT&gt;
				WScript.Echo "Invalid Resource ID!"
				WScript.Quit
			&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;End If
		End If&lt;/FONT&gt;
		
		&lt;FONT color=#009f00&gt;'Reset Err object&lt;/FONT&gt;
		Err.number = 0
		
		&lt;FONT color=#009f00&gt;'Connect to WMI&lt;/FONT&gt;
		&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; oWMI = GetObject("winMgmts:\\" &amp;amp; sSMSServer &amp;amp; "\" &amp;amp; sSMSNamespace &amp;amp; ":SMS_Collection")
		&lt;FONT color=#0000ff&gt;If &lt;/FONT&gt;Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
			WScript.Echo "Failed to connect to WMI on " &amp;amp; sSMSServer
			WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
			WScript.Quit
		&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
		
		&lt;FONT color=#009f00&gt;'Run CreateCCR Method&lt;/FONT&gt;
		oWMI.CreateCCR sResourceID, &lt;FONT color=#0000ff&gt;FALSE&lt;/FONT&gt;, 1, &lt;FONT color=#0000ff&gt;TRUE&lt;/FONT&gt;, &lt;FONT color=#0000ff&gt;FALSE&lt;/FONT&gt;, &lt;FONT color=#0000ff&gt;FALSE&lt;/FONT&gt;
		&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err.number &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
			WScript.Echo "Failed to run CreateCCR method on " &amp;amp; sSMSServer
			WScript.Echo "Error = " &amp;amp; Err.number &amp;amp; " - " &amp;amp; Err.Description
			WScript.Quit
		&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
		
		WScript.Echo "Client Install Request Sent Successfully!"
	&lt;FONT color=#0000ff&gt;End If&lt;/FONT&gt;
	
	&lt;FONT color=#009f00&gt;'Clean up objects&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; oWMI = &lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;
	
&lt;FONT color=#0000ff&gt;End Sub&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/FONT&gt;&lt;PRE&gt;&lt;/PRE&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=631435" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/rslaten/attachment/631435.ashx" length="7192" type="text/plain" /><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item><item><title>Adding a new DP to all existing packages</title><link>http://blogs.msdn.com/rslaten/archive/2006/06/08/Adding-a-new-DP-to-all-existing-packages.aspx</link><pubDate>Thu, 08 Jun 2006 19:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:622441</guid><dc:creator>rslaten</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/622441.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=622441</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=622441</wfw:comment><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;I was recently asked if I had a script to add a new DP to all existing packages in a hierarchy. I wrote something last year that does this. This is a very rough script that was written to actually troubleshoot a specific problem but it might be useful for scenarios like this. It should be noted that this script does need to be cleaned up a bit, error checking added, etc... &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;The script reads a CSV file that contains a list of primary site servers, child site codes, and package IDs. The script then connects to each primary site server, gets a list of child site codes, gets a list of DPs for the site code listed, and adds every DP at that child site to the package listed. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;Here is an example csv file&lt;BR&gt;myCentralSiteServer,CEN,CEN00001&lt;BR&gt;myCentralSiteServer,SEC,CEN00001&lt;BR&gt;myPrimarySiteServer,PRI,CEN00001&lt;BR&gt;myPrimarySiteServer,PRS,PRI00001&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;So if you ran the script against this CSV file the following would happen:&lt;BR&gt;- Read the CSV file, put this information into an array&lt;BR&gt;- Connect to myCentralSiteServer via WMI&lt;BR&gt;- Get a list of DPs for CEN&lt;BR&gt;- Add all DPs in CEN to CEN00001&lt;BR&gt;- Add all DPs in SEC to CEN00001&lt;BR&gt;- Connect to myPrimarySiteServer via WMI&lt;BR&gt;- Get a list of DPs for PRI&lt;BR&gt;- Add all DPs in PRI to CEN00001&lt;BR&gt;- Add all DPs in PRS to PRI00001&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;The interesting thing about this script is that it can be used to spread the load of package distribution over your child primary sites instead of distributing all packages from the central site.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;FONT size=2&gt;Syntax of script: cscript.exe smsdpadd.vbs myCSVfile.csv&lt;/FONT&gt; &lt;PRE&gt;&lt;DIV style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;&lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;

&lt;FONT size=2&gt;&lt;FONT color=#009f00&gt;'Rslaten 04/2005&lt;/FONT&gt;

On Error Resume Next
Dim&lt;/FONT&gt; SMSSites(), ConnTest, SysResList(), AsyncResQuery, AsyncSiteQuery, SiteList(), DPAddArr()
&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt; sysrescounter, sitecounter
WScript.Echo "SMS DP Add v1.0"
WScript.Echo ""
GetDPList
StartProcessingLoop

&lt;FONT color=#0000ff&gt;Sub&lt;/FONT&gt; StartProcessingLoop
	&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;On Error Resume Next
	Dim&lt;/FONT&gt; refWMI, SMSNameSpace, refDistPoint
	&lt;FONT color=#0000ff&gt;For&lt;/FONT&gt; i = &lt;FONT color=#0000ff&gt;LBound&lt;/FONT&gt;(SMSSites) &lt;FONT color=#0000ff&gt;to UBound&lt;/FONT&gt;(SMSSites)
		DPInfo = Split(SMSSites(i),",")
		&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; ConnTest &amp;lt;&amp;gt; DPInfo(0)&amp;amp;",Success" &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
			ConnTestInfo = Split(ConnTest,",")
			&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; ConnTestInfo(1) &amp;lt;&amp;gt; "Failed" &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
				retval = ConnectToNameSpace(DPInfo(0))
				ConnTest = DPInfo(0)&amp;amp;","&amp;amp;retval
				&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; ConnTest = DPInfo(0)&amp;amp;",Success" &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
					AsyncResQuery = ""
					AsyncSiteQuery = ""
					GetSysResList(DPInfo(0))
					&lt;FONT color=#0000ff&gt;Do While&lt;/FONT&gt; AsyncResQuery &amp;lt;&amp;gt; "Completed" &lt;FONT color=#0000ff&gt;or&lt;/FONT&gt; AsyncSiteQuery &amp;lt;&amp;gt; "Completed"
						WScript.Sleep 100
					&lt;FONT color=#0000ff&gt;Loop&lt;/FONT&gt;
					CombineArrays
					&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; refWMI = GetObject("winMgmts:\\" &amp;amp;DPInfo(0)&amp;amp;"\root\sms")
					&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; colNameSpaceQuery = refWMI.ExecQuery("select * from SMS_ProviderLocation")
					&lt;FONT color=#0000ff&gt;For Each&lt;/FONT&gt; refitem &lt;FONT color=#0000ff&gt;in&lt;/FONT&gt; colNameSpaceQuery
						SMSNameSpace = refitem.NamespacePath
					&lt;FONT color=#0000ff&gt;Next&lt;/FONT&gt;
					&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; refWMI = &lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;
					&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; refWMI = GetObject("winMgmts:" &amp;amp;SMSNameSpace)
					&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; refDistPoint = refWMI.Get("SMS_DistributionPoint").SpawnInstance_
				&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;End If
			End If
		End If&lt;/FONT&gt;
		&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; ConnTest = DPInfo(0)&amp;amp;",Success" &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
			Search = Filter(DPAddArr,"SMS_SITE="&amp;amp;Ucase(DPInfo(1)),&lt;FONT color=#0000ff&gt;TRUE&lt;/FONT&gt;,vbBinaryCompare)
			&lt;FONT color=#0000ff&gt;For&lt;/FONT&gt; y = &lt;FONT color=#0000ff&gt;LBound&lt;/FONT&gt;(Search) &lt;FONT color=#0000ff&gt;to UBound&lt;/FONT&gt;(Search)
				NewVars = Split(Search(y),",")
				refDistPoint.PackageID = DPInfo(2)
				refDistPoint.SiteCode = NewVars(2)
				refDistPoint.ServerNALPath = NewVars(1)
				refDistPoint.SiteName = NewVars(3)
				refDistPoint.Put_()
				WScript.Echo NOW &amp;amp;" - Added DP:" &amp;amp;NewVars(0)&amp;amp; " for Site:" &amp;amp;NewVars(2)&amp;amp;" to Package:"_
				&amp;amp;DPInfo(2)&amp;amp; " at Primary Site:" &amp;amp;DPInfo(0)
			&lt;FONT color=#0000ff&gt;Next&lt;/FONT&gt;
		&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;End If
	Next
End Sub&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;Sub&lt;/FONT&gt; CombineArrays
	&lt;FONT color=#0000ff&gt;On Error Resume Next&lt;/FONT&gt;
	WScript.Echo "Combining data from arrays"
	&lt;FONT color=#0000ff&gt;ReDim&lt;/FONT&gt; DPAddArr(i)
	&lt;FONT color=#0000ff&gt;For&lt;/FONT&gt; i = 0 &lt;FONT color=#0000ff&gt;to UBound&lt;/FONT&gt;(DPAddArr)
		DPAddArr(i) = ""
	&lt;FONT color=#0000ff&gt;Next&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;For&lt;/FONT&gt; i = &lt;FONT color=#0000ff&gt;LBound&lt;/FONT&gt;(SysResList) &lt;FONT color=#0000ff&gt;to UBound&lt;/FONT&gt;(SysResList)
		DP = Split(SysResList(i),",")
		Search = Filter(SiteList,DP(2),&lt;FONT color=#0000ff&gt;TRUE&lt;/FONT&gt;,vbBinaryCompare)
		SiteVars = Split(Search(0),",")
		&lt;FONT color=#0000ff&gt;ReDim Preserve&lt;/FONT&gt; DPAddArr(i)
		DPAddArr(i) = DP(0)&amp;amp;","&amp;amp;DP(1)&amp;amp;","&amp;amp;DP(2)&amp;amp;","&amp;amp;SiteVars(0)
	&lt;FONT color=#0000ff&gt;Next&lt;/FONT&gt;
	WScript.Echo "Done combining data"
&lt;FONT color=#0000ff&gt;End Sub&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;Sub&lt;/FONT&gt; GetSysResList(server)
	&lt;FONT color=#0000ff&gt;On Error Resume Next&lt;/FONT&gt;
	WScript.Echo "****************************************************"
	WScript.Echo "SMS Primary Site = " &amp;amp;UCase(server)
	WScript.Echo ""
	&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt; colSysResQuery, sink, sink2, colSiteQuery, sQuery
	sysrescounter = 0
	sitelistcounter = 0
	&lt;FONT color=#0000ff&gt;Redim&lt;/FONT&gt; SysResList(sysrescounter)
	&lt;FONT color=#0000ff&gt;Redim&lt;/FONT&gt; SiteList(sitelistcounter)
	&lt;FONT color=#0000ff&gt;For&lt;/FONT&gt; i = 0 &lt;FONT color=#0000ff&gt;to UBound&lt;/FONT&gt;(SysResList)
		SysResList(i) = ""
	&lt;FONT color=#0000ff&gt;Next&lt;/FONT&gt;
		&lt;FONT color=#0000ff&gt;For &lt;/FONT&gt;i = 0 &lt;FONT color=#0000ff&gt;to UBound&lt;/FONT&gt;(SiteList)
		SiteList(i) = ""
	&lt;FONT color=#0000ff&gt;Next&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; refWMI = GetObject("winMgmts:\\" &amp;amp;Server&amp;amp;"\root\sms")
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; colNameSpaceQuery = refWMI.ExecQuery("select * from SMS_ProviderLocation")
	&lt;FONT color=#0000ff&gt;For Each&lt;/FONT&gt; refitem &lt;FONT color=#0000ff&gt;in&lt;/FONT&gt; colNameSpaceQuery
		SMSNameSpace = refitem.NamespacePath
	&lt;FONT color=#0000ff&gt;Next&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; refWMI = &lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; refWMI = GetObject("winMgmts:" &amp;amp;SMSNameSpace)
	WScript.Echo "Querying SMS Database for SysResList data on " &amp;amp;server
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; sink = wscript.CreateObject("WbemScripting.SWbemSink","SINK_")
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; sink2 = wscript.CreateObject("WbemScripting.SWbemSink","SINK2_")
	sQuery = "select * from SMS_SystemResourceList WHERE RoleName='SMS Distribution Point'"
	colSysResQuery = refWMI.ExecQueryAsync(sink,sQuery)
	WScript.Echo "Querying SMS Database for Site data on " &amp;amp;server
	colSiteQuery = refWMI.ExecQueryAsync(sink2,"select * from SMS_Site")
&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;End Sub
Sub&lt;/FONT&gt; SINK_OnObjectReady(objObject, objAsyncContext)
	&lt;FONT color=#0000ff&gt;On Error Resume Next&lt;/FONT&gt;
	ReDim Preserve SysResList(sysrescounter)
	SysResList(sysrescounter) = objObject.ServerName&amp;amp; "," &amp;amp;objObject.NALPath&amp;amp; ","_
	&amp;amp;objObject.SiteCode
	sysrescounter = sysrescounter + 1
&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;End Sub
Sub&lt;/FONT&gt; SINK_OnCompleted(iHResult, objErrorObject, objAsyncContext)
	On Error Resume Next
	AsyncResQuery = "Completed"
	WScript.Echo "Done with SysResList data query"
&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;End Sub
Sub&lt;/FONT&gt; SINK2_OnObjectReady(objObject, objAsyncContext)
	&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;On Error Resume Next
	ReDim Preserve&lt;/FONT&gt; SiteList(Sitecounter)
	SiteList(Sitecounter) = objObject.SiteName&amp;amp; "," &amp;amp;objObject.SiteCode
	Sitecounter = Sitecounter + 1
&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;End Sub
Sub&lt;/FONT&gt; SINK2_OnCompleted(iHResult, objErrorObject, objAsyncContext)
	&lt;FONT color=#0000ff&gt;On Error Resume Next&lt;/FONT&gt;
	AsyncSiteQuery = "Completed"
	WScript.Echo "Done with Site data query"
&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;End Sub

Function&lt;/FONT&gt; ConnectToNameSpace(server)
	&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;On Error Resume Next
	Set&lt;/FONT&gt; refWMI = GetObject("winMgmts:\\" &amp;amp; Server &amp;amp; "\root\cimv2")
	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; err &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
		WScript.Echo "Failed to connect to cimv2 Namespace on " &amp;amp;server
		WScript.Echo "ERROR = " &amp;amp;Err.Description
		ConnectToNameSpace = "Failed"
	&lt;FONT color=#0000ff&gt;Else&lt;/FONT&gt;
		&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; refWMI = Nothing
		ConnectToNameSpace = "Success"
	&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;End If
End Function&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;Sub&lt;/FONT&gt; GetDPList
	&lt;FONT color=#0000ff&gt;On Error Resume Next&lt;/FONT&gt;
	TXTPATH = WScript.Arguments(0)
	WScript.Echo "Getting list of DP's from " &amp;amp;TXTPATH
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; txtFSO = CreateObject("Scripting.FileSystemObject")
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; WSHShell = WScript.CreateObject("Wscript.Shell")
	WScript.Echo "****************************************************"
	strdir = WshShell.CurrentDirectory &amp;amp; "\" &amp;amp;TXTPATH
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; WSHSHell = &lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;
	TXTPATH = strdir
	&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt; txtInputFile = txtFSO.OpenTextFile(TXTPATH)
	&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt; Err &amp;lt;&amp;gt; 0 &lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;
		WScript.Echo "Couldn't find " &amp;amp;TXTPATH
		WScript.Echo "Usage: cscript.exe smsdpadd.vbs &lt;TEXT file name&gt;"
		WScript.Quit
	&lt;FONT color=#0000ff&gt;Else&lt;/FONT&gt;
		&lt;FONT color=#0000ff&gt;While Not&lt;/FONT&gt; txtInputFile.AtEndOfStream
			FullLine = txtInputFile.ReadLine()
			&lt;FONT color=#0000ff&gt;ReDim Preserve&lt;/FONT&gt; SMSSites(SiteCounter)
			SMSSites(SiteCounter) = FullLine
			szSMSSiteQuery = SiteCounter
			SiteCounter = SiteCounter + 1
		&lt;FONT color=#0000ff&gt;Wend&lt;/FONT&gt;
		WScript.Echo "Found " &amp;amp;szSMSSiteQuery + 1 &amp;amp; " sites"
		WScript.Echo "Done building array of Sites"
		WScript.Echo "****************************************************"
		WScript.Echo ""
	&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End If
End Sub&lt;/FONT&gt;
&lt;/DIV&gt;&lt;/PRE&gt;
&lt;DIV&gt;&lt;/DIV&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=622441" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/rslaten/attachment/622441.ashx" length="2066" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item><item><title>Introduction to the SMS 2003 Management Point (MP) API</title><link>http://blogs.msdn.com/rslaten/archive/2006/04/06/Introduction-to-the-MP-API.aspx</link><pubDate>Thu, 06 Apr 2006 18:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:569958</guid><dc:creator>rslaten</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/569958.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=569958</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=569958</wfw:comment><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;The MP API was introduced in the second release of the &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=58833CD1-6DBB-45BB-BB77-163446068EF6&amp;amp;displaylang=en"&gt;SMS SDK&lt;/A&gt; (we are currently in the fourth release, version 3.1).&amp;nbsp; This API is very powerful and can be used to submit discovery, inventory, status, and metering data from a SMS or non-SMS client.&amp;nbsp; It can also be used to request information from an MP, like policies or the location of a distribution point based on an IP subnet or AD site.&amp;nbsp; &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;FONT size=2&gt;This example shows how to submit a location request to an MP via the MP API.&amp;nbsp; This can be useful for a non-SMS client to be able to find out where to install an SMS package from.&amp;nbsp; A common scenario would be a new install of the OS (maybe right after an image is applied).&amp;nbsp; You could use the MP API to find out where to install the software needed on the image in order to get the machine up to a baseline.&amp;nbsp; I created a win32 console application in Visual Studio and checked the box to add MFC support.&amp;nbsp; For this application to work the smsmsgapi.dll must be registered on the machine (regsvr32 smsmsgapi.dll).&amp;nbsp; Also, make sure smsmsgapi.h and smsmsgapi_i.c are in your project folder.&amp;nbsp; All of these files are included in the &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=58833CD1-6DBB-45BB-BB77-163446068EF6&amp;amp;displaylang=en"&gt;&lt;FONT size=2&gt;SMS SDK&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt; 
&lt;P&gt;
&lt;DIV style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #c5c5c5"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;FONT size=2&gt;&lt;FONT color=#009f00&gt;&lt;SPAN class=rem&gt;// LocationRequest.cpp : Defines the entry point for the console application.&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;// Example of how to submit a location request using the MP API&lt;/SPAN&gt;&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; &lt;SPAN class=str&gt;"stdafx.h"&lt;/SPAN&gt;
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; &lt;SPAN class=str&gt;"LocationRequest.h"&lt;/SPAN&gt;
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; &lt;SPAN class=str&gt;"SmsMsgAPI.h"&lt;/SPAN&gt;
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; &lt;SPAN class=str&gt;"SmsMsgAPI_i.c"&lt;/SPAN&gt;
&lt;FONT color=#0000ff&gt;#ifdef&lt;/FONT&gt; _DEBUG
&lt;SPAN class=preproc&gt;&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; DEBUG_NEW
&lt;SPAN class=preproc&gt;&lt;FONT color=#0000ff&gt;#endif&lt;/FONT&gt;&lt;/SPAN&gt;

CWinApp theApp;

&lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;namespace&lt;/SPAN&gt;&lt;/FONT&gt; std;

&lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;//  Macros to perform error handling and make the code cleaner.&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;SPAN class=preproc&gt;&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt;&lt;/SPAN&gt; _BEGIN \
    HRESULT __hrRetVal = S_OK; \
    { \
 
&lt;SPAN class=preproc&gt;&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt;&lt;/SPAN&gt; _END \
    } \
    __End: \
 
&lt;SPAN class=preproc&gt;&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt;&lt;/SPAN&gt; _RETVAL __hrRetVal
 
&lt;SPAN class=preproc&gt;&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt;&lt;/SPAN&gt; _CHECKHR(expr) &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;/SPAN&gt;(FAILED(expr)) { __hrRetVal=expr; &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;goto&lt;/FONT&gt;&lt;/SPAN&gt; __End; }

&lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;//Main&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&lt;/SPAN&gt; _tmain(&lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&lt;/SPAN&gt; argc, TCHAR* argv[], TCHAR* envp[])
{
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&lt;/SPAN&gt; nRetCode = 0;

    &lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;// initialize MFC and print and error on failure&lt;/FONT&gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;/SPAN&gt; (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
    {
        _tprintf(_T(&lt;SPAN class=str&gt;"Fatal Error: MFC initialization failed\n"&lt;/SPAN&gt;));
        nRetCode = 1;
    }
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;else&lt;/FONT&gt;&lt;/SPAN&gt;
    {
        &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;/SPAN&gt;(argc &amp;lt; 4)
        {
            printf(&lt;SPAN class=str&gt;"Usage:LocationRequest.exe &amp;lt;http://mpname&amp;gt; &amp;lt;CliSubnet&amp;gt; &amp;lt;CliIP&amp;gt; &amp;lt;PkgID&amp;gt; &amp;lt;ADSite&amp;gt;\n"&lt;/SPAN&gt;);
        }
        &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;else&lt;/FONT&gt;&lt;/SPAN&gt;
        {
            CString sMPIP, sClientSubnet, sClientIP, sPackageID, sADSite;
            ISmsMessaging               *pMessaging = NULL;
            ISmsMessage                 *pRequest = NULL;
            ISmsMessage                 *pReply = NULL;
            WCHAR                       *pszRequestMessage = NULL;
            WCHAR                       *pszReplyMessage = NULL;
            CString                        sNewLocationRequest;
            BSTR                        sLocationRequest = NULL;
            BSTR                        sMPIPAddress;

            &lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;//Get command line arguments&lt;/FONT&gt;&lt;/SPAN&gt;
            sMPIP = argv[1];
            sClientSubnet = argv[2];
            sClientIP = argv[3];
            sPackageID = argv[4];
            sADSite = argv[5];

            &lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;//Format XML based Location Request&lt;/FONT&gt;&lt;/SPAN&gt;
            sNewLocationRequest = &lt;/FONT&gt;&lt;FONT size=2&gt;&lt;SPAN class=str&gt;"&amp;lt;ContentLocationRequest SchemaVersion=\"1.0\"&amp;gt; \n \
&amp;lt;Package ID=\""&lt;/SPAN&gt; + sPackageID + &lt;/FONT&gt;&lt;FONT size=2&gt;&lt;SPAN class=str&gt;"\" Version=\"*\"/&amp;gt; \n \
&amp;lt;AssignedSite SiteCode=\"*\"/&amp;gt; \n \
&amp;lt;ClientLocationInfo&amp;gt; \n \
&amp;lt;ADSite Name=\""&lt;/SPAN&gt; + sADSite + &lt;/FONT&gt;&lt;FONT size=2&gt;&lt;SPAN class=str&gt;"\"/&amp;gt; \n \
&amp;lt;IPAddresses&amp;gt; \n \
&amp;lt;IPAddress SubnetAddress=\""&lt;/SPAN&gt; + sClientSubnet + &lt;SPAN class=str&gt;"\" Address=\""&lt;/SPAN&gt; + sClientIP + &lt;/FONT&gt;&lt;FONT size=2&gt;&lt;SPAN class=str&gt;"\"/&amp;gt; \n \
&amp;lt;/IPAddresses&amp;gt; \n \
&amp;lt;/ClientLocationInfo&amp;gt; \n \
&amp;lt;/ContentLocationRequest&amp;gt;"&lt;/SPAN&gt;;

            printf(&lt;SPAN class=str&gt;"\nLocation Request:\n%s"&lt;/SPAN&gt;,sNewLocationRequest);  &lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;//Print request to command line&lt;/FONT&gt;&lt;/SPAN&gt;

            sLocationRequest = sNewLocationRequest.AllocSysString();
            sMPIPAddress = sMPIP.AllocSysString();
            CoInitialize(0);

        _BEGIN

            &lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;//Create root messaging object&lt;/FONT&gt;&lt;/SPAN&gt;
            _CHECKHR( ::CoCreateInstance(
                        CLSID_SmsMessaging,
                        NULL,
                        CLSCTX_INPROC,
                        IID_ISmsMessaging,
                        (LPVOID*)&amp;amp;pMessaging) );

            &lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;//Create message object for request&lt;/FONT&gt;&lt;/SPAN&gt;
            _CHECKHR( pMessaging-&amp;gt;CreateMessage(&amp;amp;pRequest) );

            &lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;//Set the target of the message to the Location Manager endpoint&lt;/FONT&gt;&lt;/SPAN&gt;
            _CHECKHR( pRequest-&amp;gt;SetTargetEndpoint(L&lt;SPAN class=str&gt;"MP_LocationManager"&lt;/SPAN&gt;) );

            &lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;//Set the message body with the request&lt;/FONT&gt;&lt;/SPAN&gt;
            _CHECKHR( pRequest-&amp;gt;SetBodyFromString(sLocationRequest) );

            &lt;FONT color=#009f00&gt;&lt;SPAN class=rem&gt;// Invoke the targeted endpoint on the local machine with the request,&lt;/SPAN&gt;
            &lt;SPAN class=rem&gt;// and retrieve the reply.&lt;/SPAN&gt;&lt;/FONT&gt;
            _CHECKHR( pMessaging-&amp;gt;Invoke(sMPIPAddress, pRequest, &amp;amp;pReply) );

            &lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;// Extract body from reply message.&lt;/FONT&gt;&lt;/SPAN&gt;
            _CHECKHR( pReply-&amp;gt;GetBodyToString(&amp;amp;pszReplyMessage) );

            wprintf(L&lt;SPAN class=str&gt;"\n\nReply from MP:\n%s"&lt;/SPAN&gt;, (&lt;FONT color=#0000ff&gt;wchar_t&lt;/FONT&gt; *) pszReplyMessage);

        _END

            printf(&lt;SPAN class=str&gt;"\n\n%s%X"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"Return Code="&lt;/SPAN&gt;, __hrRetVal);

            &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;/SPAN&gt;(pszReplyMessage)
            {
                ::CoTaskMemFree(pszReplyMessage);
            }
            &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;/SPAN&gt;(pReply)
            {
                pReply-&amp;gt;Release();
            }
            &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;/SPAN&gt;(pszRequestMessage)
            {
                ::CoTaskMemFree(pszRequestMessage);
            }
            &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;/SPAN&gt;(pRequest)
            {
                pRequest-&amp;gt;Release();
            }
            &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;/SPAN&gt;(pMessaging)
            {
                pMessaging-&amp;gt;Release();
            }
        }
    }
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt;&lt;/SPAN&gt; nRetCode;
}&lt;/FONT&gt;
&lt;/PRE&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=569958" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item><item><title>SMS 2003 Logging</title><link>http://blogs.msdn.com/rslaten/archive/2006/03/14/SMS-2003-Logging.aspx</link><pubDate>Tue, 14 Mar 2006 22:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:551483</guid><dc:creator>rslaten</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/551483.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=551483</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=551483</wfw:comment><description>&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face=Arial&gt;SMS 2003 has many different&amp;nbsp;ways to enable additional logging in the product.&amp;nbsp; You should only enable additional logging if troubleshooting a &lt;/FONT&gt;&lt;FONT face=Arial&gt;specific issue.&amp;nbsp; Once the issue is resolved disable the logging.&amp;nbsp; Also note, in most cases when logging settings are modified the associated service (smsexec, ccmexec, etc...) needs to be restarted.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;Default Logging (&lt;/FONT&gt;&lt;/STRONG&gt;&lt;A href="http://support.microsoft.com/?kbid=241001"&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;KB241001&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;BR&gt;Where the SMS Executive service is installed there should be an HKLM\Software\Microsoft\SMS key.&amp;nbsp; Under this key there is a "Tracing" key with &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face=Arial&gt;different components listed below which contain logging settings.&amp;nbsp; These are enabled by default and the size for each log can be configured &lt;/FONT&gt;&lt;FONT face=Arial&gt;here.&amp;nbsp; This can also be configured in the UI by using SMS Service Manager.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Software Metering Processor Logging&lt;/STRONG&gt;&lt;BR&gt;Additional logging can be added for the SMS_SOFTWARE_METERING_PROCESSOR component (swmproc.log).&amp;nbsp; You can enable this under HKLM\Software\Microsoft\SMS\Components\SMS_SOFTWARE_METERING_PROCESSOR by setting the "Verbose Logging" value to 1.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Advanced Client/Management Point Logging &lt;/STRONG&gt;&lt;BR&gt;The AC/MP logs are very useful but there is additional logging that can be enabled.&amp;nbsp; It is called &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/technet/prodtechnol/sms/sms2003/techfaq/tfaq03.mspx"&gt;&lt;FONT size=2&gt;verbose and debug logging&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;.&amp;nbsp; Go to the section titled &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/technet/prodtechnol/sms/sms2003/techfaq/tfaq03.mspx"&gt;&lt;FONT size=2&gt;"How do I enable DEBUG/VERBOSE logging on the Advanced Client?".&amp;nbsp; &lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;This logging simply adds additional entries to the existing AC/MP logs.&amp;nbsp; In addition to this also do the following: &lt;BR&gt;a) Go to the key HKLM\Software\Microsoft\CCM\Logging\DebugLogging&lt;BR&gt;b) Create a new VALUE of type REG_SZ named "Enabled"&lt;BR&gt;c) In the "Enabled" value the data should be "True"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face=Arial size=2&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;NAL Logging (&lt;/FONT&gt;&lt;/STRONG&gt;&lt;A href="http://support.microsoft.com/?kbid=243385"&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;KB243385&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;BR&gt;This logging is only useful on the Legacy client (when communicating with a CAP) or on the site server when communicating with a site system &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;(like a DP).&amp;nbsp; This setting does not create a new log, instead it adds additional entries to the component that is using NAL.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;Wuser32 Logging (Legacy Remote Control) (&lt;/FONT&gt;&lt;A href="http://support.microsoft.com/?id=195859"&gt;&lt;FONT size=2&gt;KB195859&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR&gt;&lt;FONT size=2&gt;This can be enabled on the client side to assist in troubleshooting remote control issues.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;Legacy Client ODP/APM Logging (&lt;/FONT&gt;&lt;/STRONG&gt;&lt;A href="http://support.microsoft.com/?id=327999"&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;KB327999&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;BR&gt;In SMS 2.0 SP5 some logging was taken out of the Legacy client to make some of the logs easier to read.&amp;nbsp; This change was migrated to the SMS 2003 Legacy client.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Legacy Client Backup Logs&lt;/STRONG&gt;&lt;BR&gt;Sometimes when installing the legacy client the install may fail, but not get far enough to create the ms\sms\logs directory structure so you don't have any record of why the install failed.&amp;nbsp; To save these off create a folder called SMSLOGS under %TEMP%.&amp;nbsp; When the install fails again the SMS logs should be in that directory.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;SQL Tracing (&lt;/FONT&gt;&lt;A href="http://support.microsoft.com/?kbid=828363"&gt;&lt;FONT size=2&gt;KB828363&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size=2&gt;SQL Tracing is a very useful troubleshooting tool.&amp;nbsp; It adds additional entries to site server components that communicate with the SMS &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face=Arial&gt;database.&amp;nbsp; The entries it adds are similiar to what you would see if SQL Profiler were running.&amp;nbsp; This option usually adds a lot of data to the &lt;/FONT&gt;&lt;FONT face=Arial&gt;logs so it's best to increase the size of your SMS logs (at least for the component you are troubleshooting) so that you can make sure and &lt;/FONT&gt;&lt;FONT face=Arial&gt;capture the problem.&amp;nbsp; You might use this logging if inventory wasn't loading into the database properly.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;AD Discovery Verbose Logging&lt;BR&gt;&lt;/STRONG&gt;You can add additional logging to the following components:&amp;nbsp; Active Directory System Discovery (adsysdis.log), Active Directory System Group &lt;/FONT&gt;&lt;FONT face=Arial&gt;Discovery (adsysgrp.log), and Active Directory User Discovery (adusrdis.log).&amp;nbsp; To do this set the "Verbose Logs" value to 1 for one of the &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;following components located under HKLM\Software\Microsoft\SMS\Components:&lt;BR&gt;SMS_AD_SYSTEM_DISCOVERY_AGENT&lt;BR&gt;SMS_AD_SYSTEM_GROUP_DISCOVERY_AGENT&lt;BR&gt;SMS_AD_USER_DISCOVERY_AGENT&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;SMS Provider Logging (&lt;/FONT&gt;&lt;A href="http://support.microsoft.com/?kbid=295040"&gt;&lt;FONT size=2&gt;KB295040&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR&gt;&lt;FONT size=2&gt;The SMS provider runs under WMI (smsprov.dll) and is responsible for interfacing between the SMS Admin console (SDK) and the SMS SQL database.&amp;nbsp; SQL Cache logging can be enabled for the provider.&amp;nbsp; This is useful when troubleshooting console performance issues.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;Verbose WMI Logging (&lt;/FONT&gt;&lt;A href="http://support.microsoft.com/?kbid=317872"&gt;&lt;FONT size=2&gt;KB317872&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size=2&gt;Additional logging can be added for WMI, which is heavily used by the SMS Provider.&amp;nbsp; This is useful when troubleshooting any SMS Admin Console or SDK issue.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;Software Inventory Processor Verbose Logging&lt;/FONT&gt;&lt;/P&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face=Arial&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT size=2&gt;Thanks to &lt;/FONT&gt;&lt;/EM&gt;&lt;A href="http://blogs.msdn.com/hansr/"&gt;&lt;EM&gt;&lt;FONT size=2&gt;Hans Ravnaas&lt;/FONT&gt;&lt;/EM&gt;&lt;/A&gt;&lt;FONT size=2&gt;&lt;EM&gt; for this information!&lt;/EM&gt;&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;More verbose logging can be added to sinvproc.log.&amp;nbsp; This can be configured in the following registry &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;key: HKLM\Software\Microsoft\SMS\Components\SMS_SOFTWARE_INVENTORY_PROCESSOR.&lt;BR&gt;"Verbose Logging"="TRUE"&lt;BR&gt;"ArchiveReports"="TRUE"&lt;BR&gt;"DiskSpaceLimitMB"=dword:00000020&lt;BR&gt;"AgeOutLimitDays"=dword:00000007&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face=Arial&gt;The DiskSpaceLimitMB and AgeOutLimitDays values are used to archive inventory reports as they are put into the database.&amp;nbsp; The archive files are &lt;/FONT&gt;&lt;FONT face=Arial&gt;stored in SMS\inboxes\sinv.box\Temp.&amp;nbsp; This can be useful when troubleshooting inventory issues at the client.&amp;nbsp; Also note, you can archive the &lt;/FONT&gt;&lt;FONT face=Arial&gt;same reports, plus more, on the client.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;FONT size=2&gt;The following reports will be saved at the client&lt;BR&gt;&lt;/FONT&gt;&lt;EM&gt;&lt;FONT size=2&gt;Hardware Inventory&lt;BR&gt;Software Inventory&lt;BR&gt;Discovery Data&lt;BR&gt;Software Metering usage reports&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;/FONT&gt;&lt;FONT face=Arial&gt;&lt;BR&gt;&lt;FONT size=2&gt;To configure an SMS 2003 Advanced Client to save off a copy of the report it sends to its MP, create an empty file under the inventory temp directory called archive_reports.sms. The following registry value will point to the inventory temp directory:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;HKLM\Software\Microsoft\SMS\Mobile Client\Inventory ----&amp;gt; "Temp Directory".&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Examples:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;1. To save off inventory reports on a client that is not also an MP, create the &lt;BR&gt;following file:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;%systemroot%\system32\ccm\inventory\temp\archive_reports.sms&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;2. To save off inventory reports on a client that is also an MP, create the &lt;BR&gt;following file:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&amp;lt;x&amp;gt;:\sms_ccm\inventory\temp\archive_reports.sms&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;The XML file will be saved in the inventory\temp folder.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Note: Delete the archive_reports.sms file when you are done trouble-shooting.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;* One additional step is needed to create metering reports.&amp;nbsp; Create a directory under ccm\metering\temp called "archive".&amp;nbsp; The reports will show up there&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=551483" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item><item><title>Getting a list of protected DPs in your hierarchy</title><link>http://blogs.msdn.com/rslaten/archive/2006/03/13/GetProtectedDPs.aspx</link><pubDate>Mon, 13 Mar 2006 23:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:550722</guid><dc:creator>rslaten</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/rslaten/comments/550722.aspx</comments><wfw:commentRss>http://blogs.msdn.com/rslaten/commentrss.aspx?PostID=550722</wfw:commentRss><wfw:comment>http://blogs.msdn.com/rslaten/rsscomments.aspx?PostID=550722</wfw:comment><description>&lt;P&gt;&lt;FONT face=Arial&gt;&lt;FONT size=2&gt;I was recently asked if there was a way, via the &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=58833CD1-6DBB-45BB-BB77-163446068EF6&amp;amp;displaylang=en"&gt;&lt;FONT size=2&gt;SDK&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;, to list out all your protected DPs and their configured boundaries.&amp;nbsp; I found that this information is available using the &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=58833CD1-6DBB-45BB-BB77-163446068EF6&amp;amp;displaylang=en"&gt;&lt;FONT size=2&gt;SDK&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt; but not easily accessible.&amp;nbsp; I have attached a script that is an example of how to do this.&amp;nbsp; It lists out all DPs in your hierarchy, identifies whether they are protected, and then lists any configured boundaries.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;-Russ&lt;/FONT&gt;&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: 1px solid; COLOR: #000000; PADDING-TOP: 1px; BORDER-BOTTOM: 1px solid; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;PRE class=csharpcode&gt;&lt;FONT size=2&gt;&lt;FONT color=#009f00&gt;&lt;SPAN class=rem&gt;'Rslaten 03/2006&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;'Gets protected DPs&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;'Pass Central site server as first argument&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;'Needs more error checking added&lt;/SPAN&gt;&lt;/FONT&gt;

WScript.Echo &lt;SPAN class=str&gt;""&lt;/SPAN&gt;
WScript.Echo &lt;SPAN class=str&gt;"GetProtectedDPs"&lt;/SPAN&gt;
WScript.Echo &lt;SPAN class=str&gt;"Usage: cscript.exe GetProtectedDPs.vbs &amp;lt;CenSiteServerName&amp;gt;"&lt;/SPAN&gt;
WScript.Echo &lt;SPAN class=str&gt;"Example: cscript.exe GetProtectedDPs.vbs myCentralSiteServer"&lt;/SPAN&gt;
WScript.Echo &lt;SPAN class=str&gt;""&lt;/SPAN&gt;

&lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;'Globals&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt;&lt;/SPAN&gt; oServices

Main

&lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Sub&lt;/FONT&gt;&lt;/SPAN&gt; Main
    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;On&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Error&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Resume&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Next&lt;/SPAN&gt;&lt;/FONT&gt;
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt;&lt;/SPAN&gt; sNameSpace, sSiteServer, sSiteCode, oLocator
    sSiteServer = WScript.Arguments(0)
    sNameSpace = GetSMSNameSpace(sSiteServer)
    sSiteCode = Right(sNameSpace, 3)
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt;&lt;/SPAN&gt; oLocator = CreateObject(&lt;SPAN class=str&gt;"WbemScripting.SWbemLocator"&lt;/SPAN&gt;)
    
    &lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;'Connect to WMI&lt;/FONT&gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt;&lt;/SPAN&gt; oServices = oLocator.ConnectServer(sSiteServer, sNameSpace,,,,,128)
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt;&lt;/SPAN&gt; Err.number &amp;lt;&amp;gt; 0 &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;&lt;/SPAN&gt;
        WScript.Echo &lt;SPAN class=str&gt;"Error connecting to "&lt;/SPAN&gt; &amp;amp;sNameSpace&amp;amp; &lt;SPAN class=str&gt;" on "&lt;/SPAN&gt; &amp;amp;WScript.Arguments(0)&amp;amp; &lt;SPAN class=str&gt;": "&lt;/SPAN&gt; &amp;amp;Err.Number
        &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt;&lt;/SPAN&gt; oLocator = &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt;&lt;/SPAN&gt; oServices = &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;&lt;/SPAN&gt;
        WScript.Quit
    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt;&lt;/FONT&gt;    
    
    &lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;'Refresh SCF&lt;/FONT&gt;&lt;/SPAN&gt;
    RefreshSCF(sSiteCode)
    
    &lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;'QueryDPs&lt;/FONT&gt;&lt;/SPAN&gt;
    QueryDPs(sSiteCode)
&lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt;&lt;/FONT&gt;

&lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;'Queries DPs&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Sub&lt;/FONT&gt;&lt;/SPAN&gt; QueryDPs(sSiteCode)
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt;&lt;/SPAN&gt; collDP, oRes, sStart, aProps, oProp, aPropList, oPropList, oValue
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt;&lt;/SPAN&gt; collDP = oServices.ExecQuery(&lt;SPAN class=str&gt;"select * from sms_sci_sysresuse where SiteCode = '"&lt;/SPAN&gt;&amp;amp;sSiteCode&amp;amp;&lt;SPAN class=str&gt;"'"&lt;/SPAN&gt;)
    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;For&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;each&lt;/SPAN&gt;&lt;/FONT&gt; oRes &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;in&lt;/FONT&gt;&lt;/SPAN&gt; collDP
        &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt;&lt;/SPAN&gt; oRes.RoleName = &lt;SPAN class=str&gt;"SMS Distribution Point"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;&lt;/SPAN&gt;
            sStart = InStr(oRes.NALPath,&lt;SPAN class=str&gt;"=\\"&lt;/SPAN&gt;) + 3
            sFinish = InStr(oRes.NALPath,&lt;SPAN class=str&gt;"]MSWNET"&lt;/SPAN&gt;) - 2
            sDP = mid(oRes.NALPath,sStart,sFinish-sStart)
            WScript.Stdout.Write sDP
            aProps = oRes.Props
            aPropList = oRes.PropLists
            &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;For&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;each&lt;/SPAN&gt;&lt;/FONT&gt; oProp &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;in&lt;/FONT&gt;&lt;/SPAN&gt; aProps
                &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt;&lt;/SPAN&gt; oProp.PropertyName = &lt;SPAN class=str&gt;"IsProtected"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;&lt;/SPAN&gt;
                    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt;&lt;/SPAN&gt; oProp.Value = 1 &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;&lt;/SPAN&gt;
                        WScript.Stdout.Write &lt;SPAN class=str&gt;" (Protected)"&lt;/SPAN&gt; &amp;amp; vbCrLf
                    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Else&lt;/FONT&gt;&lt;/SPAN&gt;
                        WScript.Stdout.Write &lt;SPAN class=str&gt;" (UnProtected)"&lt;/SPAN&gt; &amp;amp; vbCrLf
                    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt;
                &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;Next&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;For&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;each&lt;/SPAN&gt;&lt;/FONT&gt; oPropList &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;in&lt;/FONT&gt;&lt;/SPAN&gt; aPropList
                &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt; &lt;/FONT&gt;oPropList.PropertyListName = &lt;SPAN class=str&gt;"Protected Boundary"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;&lt;/SPAN&gt;
                    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;For&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;each&lt;/SPAN&gt;&lt;/FONT&gt; oValue &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;in&lt;/FONT&gt;&lt;/SPAN&gt; oPropList.Values
                        &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt;&lt;/FONT&gt; oValue
                            &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Case&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class=str&gt;"IP Subnets"&lt;/SPAN&gt;
                                WScript.Stdout.Write vbTab &amp;amp; &lt;SPAN class=str&gt;"Protected Boundary - IP Subnet: "&lt;/SPAN&gt;
                            &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Case&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class=str&gt;"AD Site Name"&lt;/SPAN&gt;
                                WScript.Stdout.Write vbTab &amp;amp; &lt;SPAN class=str&gt;"Protected Boundary - AD Site Name: "&lt;/SPAN&gt;
                            &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Case&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class=str&gt;"IP Ranges"&lt;/SPAN&gt;
                                WScript.Stdout.Write vbTab &amp;amp; &lt;SPAN class=str&gt;"Protected Boundary - IP Ranges: "&lt;/SPAN&gt;
                            &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Else&lt;/SPAN&gt;&lt;/FONT&gt;
                                WScript.Stdout.Write oValue &amp;amp; vbCrLf
                        &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;&lt;/FONT&gt;
                    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;Next&lt;/SPAN&gt;            
                &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;Next&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;Next&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;Set&lt;/SPAN&gt;&lt;/FONT&gt; collDP = &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt;&lt;/FONT&gt;

&lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;'Refreshes site control in WMI&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Sub&lt;/FONT&gt;&lt;/SPAN&gt; RefreshSCF(sSiteCode)
    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;On&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Error&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Resume&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Next&lt;/SPAN&gt;&lt;/FONT&gt;
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt;&lt;/SPAN&gt; sQry, colSysRes
    sQry = &lt;SPAN class=str&gt;"select * from SMS_SiteControlFile where FileType = 1 and SiteCode = '"&lt;/SPAN&gt; &amp;amp;sSiteCode&amp;amp; &lt;SPAN class=str&gt;"'"&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt;&lt;/SPAN&gt; colSysRes = oServices.ExecQuery(sQry)
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt;&lt;/SPAN&gt; Err.number &amp;lt;&amp;gt; 0 &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;&lt;/SPAN&gt;
        WScript.Echo &lt;SPAN class=str&gt;"Unable to query SMS Provider"&lt;/SPAN&gt;
        WScript.Echo &lt;SPAN class=str&gt;"Query: "&lt;/SPAN&gt; &amp;amp; sQry
        WScript.Echo &lt;SPAN class=str&gt;"Error = "&lt;/SPAN&gt; &amp;amp; Err.number &amp;amp; &lt;SPAN class=str&gt;" - "&lt;/SPAN&gt; &amp;amp; Err.Description
        WScript.Quit
    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt;&lt;/FONT&gt;
    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;For&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;each&lt;/SPAN&gt;&lt;/FONT&gt; SCI &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;in&lt;/FONT&gt;&lt;/SPAN&gt; colSysRes
        SCI.Refresh
    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;Next&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;Set&lt;/SPAN&gt;&lt;/FONT&gt; colSysRes = &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt;&lt;/FONT&gt;

&lt;SPAN class=rem&gt;&lt;FONT color=#009f00&gt;'Gets SMS Namespace&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Function&lt;/FONT&gt;&lt;/SPAN&gt; GetSMSNameSpace(SiteServer)
    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;On&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Error&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Resume&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Next&lt;/SPAN&gt;&lt;/FONT&gt;
    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; &lt;/FONT&gt;colNameSpaceQuery, refitem, refWMI
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt;&lt;/SPAN&gt; refWMI = GetObject(&lt;SPAN class=str&gt;"winMgmts:\\"&lt;/SPAN&gt; &amp;amp;SiteServer&amp;amp;&lt;SPAN class=str&gt;"\root\sms"&lt;/SPAN&gt;)
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;If&lt;/FONT&gt;&lt;/SPAN&gt; Err.number &amp;lt;&amp;gt; 0 &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Then&lt;/FONT&gt;&lt;/SPAN&gt;
        WScript.Echo &lt;SPAN class=str&gt;"Error connecting to SMS namespace on "&lt;/SPAN&gt; &amp;amp;SiteServer
        WScript.Quit
    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt;&lt;/FONT&gt;
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt;&lt;/SPAN&gt; colNameSpaceQuery = refWMI.ExecQuery(&lt;SPAN class=str&gt;"select * from SMS_ProviderLocation"&lt;/SPAN&gt;)
    &lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;For&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Each&lt;/SPAN&gt;&lt;/FONT&gt; refitem &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;in&lt;/FONT&gt;&lt;/SPAN&gt; colNameSpaceQuery
        GetSMSNameSpace = refitem.NamespacePath
   &lt;FONT color=#0000ff&gt; &lt;SPAN class=kwrd&gt;Next&lt;/SPAN&gt;&lt;/FONT&gt;
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt;&lt;/SPAN&gt; colNameSpaceQuery = &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt;&lt;/SPAN&gt; refitem = &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Set&lt;/FONT&gt;&lt;/SPAN&gt; refWMI = &lt;SPAN class=kwrd&gt;&lt;FONT color=#0000ff&gt;Nothing&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;FONT color=#0000ff&gt;&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; Function&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=550722" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/rslaten/attachment/550722.ashx" length="1366" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/rslaten/archive/tags/SMS+2003/default.aspx">SMS 2003</category></item></channel></rss>