<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://myitforum.com/cs2/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>Jeremy Young at myITforum.com : Patch Management</title><link>http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Patch+Management/default.aspx</link><description>Tags: Patch Management</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 SP2 (Build: 31113.47)</generator><item><title>PowerShell Module For ConfigMgr OnDemand Patch Management</title><link>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/08/29/PowerShell-Module-for-ConfigMgr-OnDemand-Patch-Management.aspx</link><pubDate>Wed, 29 Aug 2012 16:15:00 GMT</pubDate><guid isPermaLink="false">8e8f7986-475c-475d-bdc9-a1b3a63b955b:161481</guid><dc:creator>JeremyYoung</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://myitforum.com/cs2/blogs/jeremyyoung/rsscomments.aspx?PostID=161481</wfw:commentRss><comments>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/08/29/PowerShell-Module-for-ConfigMgr-OnDemand-Patch-Management.aspx#comments</comments><description>&lt;p&gt;&lt;font size="2" face="Consolas"&gt;I developed a PowerShell module that will scan for update compliance or launch a task sequence to install required security updates (or any advertised task sequence) on either a single machine, or multiple machines using multithreading.&amp;nbsp; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Consolas"&gt;The OnDemand module is a supplemental tool for our automated patching service. Our automated patching solution of enrolling a server in a monthly maintenance window and having ConfigMgr patch it works for most of our servers but there are times when a server owner needs more control over when a server is patched.&amp;nbsp; For example, a critical business process may require a server to be patched outside of the scheduled maintenance window.&amp;nbsp; Likewise, there are servers that can’t us a routine monthly maintenance window because they require downtime approvals from their customers.&amp;nbsp; The OnDemand Patch Management module fills this gap.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Consolas"&gt;I have blogged about individual components that are the foundation of module in previous posts:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/03/29/powershell-script-to-check-configmgr-agent-software-update-compliance.aspx" target="_blank"&gt;&lt;font size="2" face="Consolas"&gt;PowerShell Script to Check ConfigMgr Agent Software Update Compliance&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/02/28/powershell-script-to-run-configmgr-task-sequence-on-demand.aspx" target="_blank"&gt;&lt;font size="2" face="Consolas"&gt;PowerShell Script to Run ConfigMgr Task Sequence On-Demand&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Consolas"&gt;I’ve wrapped updated versions of the code in these posts (and some new code) into a pipeline-friendly module with a function that controls the processing options. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Consolas"&gt;To get started you’ll need to us the PowerShell command [&lt;em&gt;&lt;font color="#4bacc6"&gt;Import-Module ConfigMgr-OnDemandPatchManagement.psm1&lt;/font&gt;&lt;/em&gt;].&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Consolas"&gt;The function [&lt;font color="#4bacc6"&gt;Invoke-OnDemandPatchManagement&lt;/font&gt;] is the main method of interacting with the module; it has parameters and switches available to process an input list of machines (&lt;font color="#4bacc6"&gt;ComputerName&lt;/font&gt;), launch selected actions (&lt;font color="#4bacc6"&gt;Scan | Patch | Test&lt;/font&gt;)&amp;nbsp; and switch options for enabling multithreading (&lt;font color="#4bacc6"&gt;F&lt;/font&gt;&lt;font color="#4bacc6"&gt;ast&lt;/font&gt;) , which uses a slightly modified version of &lt;/font&gt;&lt;a href="http://poshcode.org/2621" target="_blank"&gt;&lt;font size="2" face="Consolas"&gt;Split-Job&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Consolas"&gt;.&amp;nbsp; There are also filters (&lt;font color="#4bacc6"&gt;Compliant&lt;/font&gt;&lt;font color="#4bacc6"&gt; | NonCompliant&lt;/font&gt;) available to further limit the processing.&amp;nbsp; Additionally, the module can be used to launch any advertised task sequence by name via the (&lt;font color="#4bacc6"&gt;CustomTaskSequenceName&lt;/font&gt;) parameter.&lt;/font&gt;&lt;/p&gt;
&lt;h5 align="left"&gt;&lt;font style="BACKGROUND-COLOR:#cccccc;" color="#000000" face="Consolas"&gt;&lt;em&gt;Use the Get-Help function on the module to view options, parameters and syntax examples&lt;/em&gt;&lt;/font&gt;&lt;/h5&gt;
&lt;p&gt;&lt;font size="2" face="Consolas"&gt;Things you’ll need to configure in Configuration Manager:&lt;/font&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;font size="2" face="Consolas"&gt;Task Sequence&lt;/font&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;font color="#666666"&gt;&lt;font size="2" face="Consolas"&gt;Inside the ConfigMgr console you will need to create a task sequence to handle the security update patching.&amp;nbsp; The task sequence names I chose in the &lt;font color="#666666"&gt;module&lt;/font&gt; are “&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;OnDemand Security Update Patching&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;” for the patch action and “&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;OnDemand Test Package&lt;/font&gt;&lt;font size="2" face="Consolas"&gt;” for the test action.&amp;nbsp; The download link below contains xml exports of example task sequences that can be imported.&amp;nbsp; Else you can update the package name specified in the global variables to match what you already have deployed or use the &lt;font color="#4bacc6"&gt;CustomTaskSequence&lt;/font&gt; parameter.&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Consolas"&gt; &lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;font size="2" face="Consolas"&gt;Advertisements &lt;/font&gt;
&lt;ul&gt;
&lt;li&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#666666"&gt;In order for client’s to access the task sequence they will need to have an advertisement targeted at them; the least impactful way to accomplish this is to create an advertisement that has a mandatory date that client’s will never hit, like some random date in the year 2020.&lt;/font&gt; &lt;/font&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#333333"&gt;Software Update Deployment Policy&lt;/font&gt; &lt;/font&gt;&lt;/font&gt;
&lt;ul&gt;
&lt;li&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#666666"&gt;Client’s will need to be targeted with one or more software update deployment policies that contain required security updates (assume you already have this in place…).&lt;/font&gt; &lt;/font&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;font size="2" face="Consolas"&gt;A couple of notes about the actions performed by this module:&lt;/font&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;font size="2" face="Consolas"&gt;The module uses a slightly modified version of &lt;/font&gt;&lt;a href="http://gallery.technet.microsoft.com/scriptcenter/7bae3d39-c6c3-4a8a-8c98-1b8851bd2cbe" target="_blank"&gt;&lt;font size="2" face="Consolas"&gt;Get-WMICustom&lt;/font&gt;&lt;/a&gt;&amp;nbsp;&lt;font size="2" face="Consolas"&gt;to interact with WMI.&lt;/font&gt;&lt;/li&gt;
&lt;li&gt;&lt;font size="2" face="Consolas"&gt;The &lt;font color="#4bacc6"&gt;Patch&lt;/font&gt; action will always perform the &lt;font color="#4bacc6"&gt;Scan&lt;/font&gt; action first and only initiate the patching task sequence if a machine is found &lt;font color="#4bacc6"&gt;NonCompliant&lt;/font&gt;. &lt;/font&gt;&lt;/li&gt;
&lt;li&gt;&lt;font size="2" face="Consolas"&gt;If no &lt;font color="#4bacc6"&gt;ComputerName&lt;/font&gt; value is passed in the selected action will happen on the local machine running the module. &lt;/font&gt;&lt;/li&gt;
&lt;li&gt;&lt;font size="2" face="Consolas"&gt;If the &lt;font color="#4bacc6"&gt;ComputerName&lt;/font&gt; input only contains a single machine name Split-Job is skipped; likewise, multithreading is not used by default so the list of machines is processed serially. Split-Job will be used if the count of machines is greater than one but it will be limited to a single thread.&amp;nbsp; The &lt;font color="#4bacc6"&gt;Fast&lt;/font&gt; switch will enable multithreading and uses ten threads by default. &lt;/font&gt;&lt;/li&gt;
&lt;li&gt;&lt;font size="2" face="Consolas"&gt;By default the module will monitor the task sequence execution until it finishes, even if the machine being monitored reboots; will not work on local machine executions cause the process will be terminated on reboot (future design change). The &lt;font color="#4bacc6"&gt;NoWaitForFinish&lt;/font&gt; switch will override this behavior and the module will only wait for the task sequence to start before returning; useful to blast out task sequence executions on a list of machines as fast as possible. &lt;/font&gt;&lt;/li&gt;
&lt;li&gt;&lt;font size="2" face="Consolas"&gt;If the &lt;font color="#4bacc6"&gt;Patch&lt;/font&gt; action launches the task sequence after the execution finishes another Scan action is performed and the object will return a state message of “Patched” if the machine is found compliant after patching. &lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;font size="2" face="Consolas"&gt;&lt;font color="#333333"&gt;OnDemand Patch Management Module v1.95&lt;/font&gt; - &lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/OnDemand%20Patch%20Management/ConfigMgr-OnDemandPatchManagement.zip" target="_blank"&gt;&lt;font color="#0000ff"&gt;Link&lt;/font&gt;&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Consolas"&gt;I hope you find this module useful; happy patching OnDemand!&lt;/font&gt;&lt;/p&gt;&lt;img src="http://myitforum.com/cs2/aggbug.aspx?PostID=161481" width="1" height="1"&gt;</description><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/SCCM/default.aspx">SCCM</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/ConfigMgr/default.aspx">ConfigMgr</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Patch+Management/default.aspx">Patch Management</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/DataCenter/default.aspx">DataCenter</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Task+Sequence/default.aspx">Task Sequence</category></item><item><title>Q&amp;A from SCCM GURU Event - Datacenter Configuration Management</title><link>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/06/22/Q-and-A-from-SCCM-GURU-Event-on-Datacenter-Configuration-Management.aspx</link><pubDate>Fri, 22 Jun 2012 23:38:00 GMT</pubDate><guid isPermaLink="false">8e8f7986-475c-475d-bdc9-a1b3a63b955b:161263</guid><dc:creator>JeremyYoung</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://myitforum.com/cs2/blogs/jeremyyoung/rsscomments.aspx?PostID=161263</wfw:commentRss><comments>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/06/22/Q-and-A-from-SCCM-GURU-Event-on-Datacenter-Configuration-Management.aspx#comments</comments><description>&lt;p&gt;Thanks to everyone who attended the SCCM GURU event I presented, if you missed it you can catch it on the replay – &lt;a href="http://info.bdna.com/20120613Webcast-SCCMGuru-JeremyYoung_ReplayRegistration.html"&gt;link&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here are my answers to questions raised during the session.&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Q: ­Is the patch management service on ConfigMgr for only Windows/IE patches, for all Microsoft products (e.g. Office), or for all products Microsoft and non-Microsoft?­ &lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;A: The Software Update &lt;/font&gt;&lt;a href="http://technet.microsoft.com/en-us/library/bb633264.aspx" target="_blank"&gt;feature&lt;/a&gt;&lt;font color="#000000" face="Consolas"&gt;&lt;/font&gt;&lt;font color="#000000" face="Consolas"&gt; in ConfigMgr is capable of installing patches for any product supported by the Windows Update catalog.&amp;#160; You can also extend the software update catalog using the &lt;/font&gt;&lt;a href="http://technet.microsoft.com/en-us/systemcenter/bb741049.aspx" target="_blank"&gt;System Center Custom Updates Publisher&lt;/a&gt;&lt;font color="#000000" face="Consolas"&gt;&lt;/font&gt;&lt;font color="#000000" face="Consolas"&gt; tool to deploy 3rd party update catalogs (like Adobe, Dell, etc.) or even manually defined updates.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Q: ­On the SUM Deployment policy, what mechanism did you use to cause the updates to download or was it only to get the advertisements?­ &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;And&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Q: ­If you have a Software Update Deployment become mandatory before your maintenance window begins, patches will be cached outside of the maintenance window? Is that correct?­&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;A: When a SUM Deployment policy is past deadline the ConfigMgr agent will automatically background download the applicable updates. &lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;We want servers to background download the updates all the time so our SUM Deployment policy is always set past the deadline and an unreachable (20+ years in the future) collection level maintenance window on the ‘All Systems’ collection keeps machines from installing updates before the advertisements start the patching task sequence.&amp;#160; &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;Read more details in one of my previous blog posts:&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;&lt;a title="SCCM Patch Management Using The Task Sequence Engine" href="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2011/11/23/sccm-patch-management-using-the-task-sequence-engine.aspx"&gt;SCCM Patch Management Using The Task Sequence Engine&lt;/a&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Q: ­If Bit Locker has been implemented in the environment, does this add to the complexity of rolling out patches? Can some patches corrupt Bit Locker?­&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;A: I don’t think Bit Locker adds any complexity to patch deployments and I’m not aware of any corruption with patches.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Q: Is the only way to do multi-pass patching to use Task Sequences? ­ &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;A: Outside of creating a custom script, the task sequence engine presents the easiest and most predictable way to do multi-pass patching.&amp;#160; &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;The main reason we use multi-pass patching is to install patches that result from a baseline upgrade, like a service pack.&amp;#160; &lt;/font&gt;&lt;font color="#000000" face="Consolas"&gt;For example, if a machine is running Office 2010 RTM and we authorize SP1 – the first patching pass would detect and install SP1 and the second pass would detect and install any post-SP1 security patches that now are required on the machine as a result of the service pack upgrade.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Q: Where would I find the &amp;quot;Patch Now&amp;quot; PowerShell stuff?&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;And&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Q: ­Would you suggest using your &amp;quot;patch now&amp;quot; PowerShell stuff for a zero-day exploit or an out of band patch?­ &lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;A: I&amp;#39;ve written two previous blog entries on the subject of initiating task sequences (which we use for patching – &lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2011/11/23/sccm-patch-management-using-the-task-sequence-engine.aspx"&gt;link&lt;/a&gt;) on-demand:&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;a title="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/02/28/powershell-script-to-run-configmgr-task-sequence-on-demand.aspx" href="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/02/28/powershell-script-to-run-configmgr-task-sequence-on-demand.aspx"&gt;PowerShell Script to Run ConfigMgr Task Sequence On-Demand&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;a title="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/03/29/powershell-script-to-check-configmgr-agent-software-update-compliance.aspx" href="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/03/29/powershell-script-to-check-configmgr-agent-software-update-compliance.aspx"&gt;PowerShell Script to Check ConfigMgr Agent Software Update Assignment Compliance&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Consolas"&gt;I am finishing up a blog post with an updated version of this code that is wrapped in a PowerShell module; check back with my blog soon!&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Consolas"&gt;As far as use in a zero-day exploit the on-demand scripts prove very useful for our server owners as they can determine their compliance or patch their machines as soon as the ConfigMgr packages are ready to go.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Q: ­Where is this health check script?&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;A: The health check script isn’t something I’ve blogged about yet; the script itself run a pretty basic set of checks against a list of machines that are not reached (no agent installed) or not healthy (hardware inventory or update scan).&amp;#160; The real “magic” of the check script is that it logs to our SQL database allowing us to collect data on machines where we have no agent, e.g., is the machine responding to a ping request? Are there free space issues on the OS drive? Can we connect to WMI? Any errors in the ccmsetup log? And so on…&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Consolas"&gt;The check script is also constantly updated as we identify fixes for common issues they get integrated into the check script to either auto-fix or at the very least report on them.&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Consolas"&gt;I’ll consider this topic for a future blog post.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Q: Seems we overcomplicate. Why not just run on auto updates on systems?­ &lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;A: &lt;/font&gt;&lt;font color="#000000" face="Consolas"&gt;In the datacenter space we need to be predictable about downtimes for servers, e.g. maintenance windows.&amp;#160; We also need the ability to in-line software deployments alongside security updates, run multiple security update install passes, dynamic targeting, handle any reboots, pre/post patching scripts and the list goes on…&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;If the main goal is just patching and rebooting machines then automatic updates or Windows Server Update Services (WSUS) is a decent tool for the job.&amp;#160; &lt;/font&gt;&lt;font color="#000000" face="Consolas"&gt;ConfigMgr is much more than just a patching tool, and while&lt;font color="#000000" face="Consolas"&gt; the method may seem overly complicated ConfigMgr allows us to deliver a much more robust service offering.&amp;#160; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#0000ff"&gt;Q: Can you talk about the disaster recovery plans for your ConfigMgr Infrastructure?&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;A: Our current disaster recovery plan includes warm-standby virtual servers shadowing each of our Site Servers.&amp;#160; The standby servers are running a blank OS install (no SQL or ConfigMgr installed) with the same drive letter/size configuration as the server they shadow; each morning they replicate a copy of the drives used for ConfigMgr backups (which contains a backup of the Site and SQL databases) as well as the live ConfigMgr folder (which contains all the inbox folders, package files, and other data).&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;If we were to lose a primary site server for example we could pretty quickly rename the standby server to the name of the lost primary site server, install SQL, restore the databases from backup and then install ConfigMgr and restore the Site database and be up and running again.&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;We have high-availability for the ConfigMgr roles like Management Points and Distribution Points and most of the other ConfigMgr roles require minimal effort to install on another server in the hierarchy in cases of disaster.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;   &lt;blockquote&gt;     &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;&lt;/font&gt;&lt;/p&gt;   &lt;/blockquote&gt;   &lt;font color="#0000ff"&gt;Q: How big is the team you work on that runs the ConfigMgr datacenter infrastructure?&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;A: My immediate team that supports a ConfigMgr for ~25-30k datacenter servers consists of three service engineers (myself included), one service manager and a small (2-3 persons per shift) tiered support team in India.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Q: What are your plans for upgrading to ConfigMgr 2012?&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#000000" face="Consolas"&gt;A: We plan to be upgraded to ConfigMgr 2012 within the next three to four months; currently we are deploying a parallel infrastructure of virtual machines running a ConfigMgr 2012 hierarchy.&amp;#160; Once that’s complete we will finalize service continuity testing (making sure automation and reporting functions still work) and then begin migrating clients in a phased approach.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font face="Consolas"&gt;Again, thanks for attending the webcast – if you have additional questions please leave them as comments and I’ll get them answered.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://myitforum.com/cs2/aggbug.aspx?PostID=161263" width="1" height="1"&gt;</description><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/SCCM/default.aspx">SCCM</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/ConfigMgr/default.aspx">ConfigMgr</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Patch+Management/default.aspx">Patch Management</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/DataCenter/default.aspx">DataCenter</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Task+Sequence/default.aspx">Task Sequence</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/SCCM+GURU/default.aspx">SCCM GURU</category></item><item><title>Filtering ConfigMGR Software Updates IN SQL</title><link>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/05/30/filtering-sccm-software-updates-in-sql.aspx</link><pubDate>Thu, 31 May 2012 06:54:32 GMT</pubDate><guid isPermaLink="false">8e8f7986-475c-475d-bdc9-a1b3a63b955b:161201</guid><dc:creator>JeremyYoung</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://myitforum.com/cs2/blogs/jeremyyoung/rsscomments.aspx?PostID=161201</wfw:commentRss><comments>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/05/30/filtering-sccm-software-updates-in-sql.aspx#comments</comments><description>&lt;p&gt;The Datacenter environment that I manage with ConfigMgr for security updates consists of only Windows server platforms, running English builds, and no Itanium architecture.&amp;#160; So when it came time to build automation for authorizing security updates I wanted to ensure that only updates applicable to my environment were approved for deployment.&lt;/p&gt;  &lt;p&gt;Creating this filtered list in SQL turned out to be much more complicated than I had anticipated but this &lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/ConfigMgr_FilteredSoftwareUpdates.zip" target="_blank"&gt;query&lt;/a&gt; was the result.&lt;/p&gt;  &lt;p&gt;It’s expensive to authorize unnecessary updates because they have associated resource costs:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Agents use processing time on the unnecessary updates to see if they apply to them &lt;/li&gt;    &lt;li&gt;ConfigMgr infrastructure servers waste disk space storing unnecessary update files &lt;/li&gt;    &lt;li&gt;Replication of ConfigMgr update packages takes longer because of unnecessary files &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;ConfigMgr relies on the Windows Server Update Services (WSUS) catalog and agent to handle security update patching; WSUS natively allows you to filter the update catalog and remove unneeded languages and some of the client/desktop platform updates but currently there isn’t any way to filter updates by architecture, 32bit or 64bit or specifically exclude just the 64bit Itanium architecture.&amp;#160; &lt;/p&gt;  &lt;p&gt;I was able to overcome this hurdle by filtering in SQL (using &lt;font face="Consolas"&gt;PATINDEX()&lt;/font&gt;) against the title of the update or the content web URL (Itanium patches have a pattern of %ia64%).&amp;#160; Of course there are a few update publishers who don’t have consistent publishing titles or they bundle updates for all platforms/architectures into a single update (.Net/SQL updates are the worst offenders); to solve this I have additional &lt;font face="Consolas"&gt;PATINDEX()&lt;/font&gt; checks to make sure the title/URL of the update being filtered doesn’t also contain the string pattern “server”.&lt;/p&gt;  &lt;p&gt;The next problem was finding a distinct list of updates in the database; ConfigMgr normalizes the update metadata across a different tables and each security update gets broken into many rows.&amp;#160; For example, each security update for the Windows Server platforms will show up as at least 8 unique rows:&lt;/p&gt;  &lt;p&gt;Security Update for Windows Server 2003 x64 Edition (KBxxxxxxx)    &lt;br /&gt;Security Update for Windows Server 2003 for Itanium-based Systems (KBxxxxxxx)     &lt;br /&gt;Security Update for Windows Server 2003 (KBxxxxxxx)     &lt;br /&gt;Security Update for Windows Server 2008 x64 Edition (KBxxxxxxx)     &lt;br /&gt;Security Update for Windows Server 2008 R2 for Itanium-based Systems (KBxxxxxxx)     &lt;br /&gt;Security Update for Windows Server 2008 (KBxxxxxxx)     &lt;br /&gt;Security Update for Windows Server 2008 R2 x64 Edition (KBxxxxxxx)     &lt;br /&gt;Security Update for Windows Server 2008 for Itanium-based Systems (KBxxxxxxx)&lt;/p&gt;  &lt;p&gt;Another interesting tidbit I learned about ConfigMgr software updates data storage is that there are three CI (configuration items) fields that make up a distinct software update:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font face="Consolas"&gt;CI_UniqueID&lt;/font&gt; (you’d think we could stop here since this field is named &lt;em&gt;unique&lt;/em&gt;…)       &lt;ul&gt;       &lt;li&gt;Sourced from the [&lt;font face="Consolas"&gt;v_UpdateInfo&lt;/font&gt;] view &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;font face="Consolas"&gt;CI_ID&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;Also sourced from the [&lt;font face="Consolas"&gt;v_UpdateInfo&lt;/font&gt;] view &lt;/li&gt;        &lt;li&gt;Joined to the [&lt;font face="Consolas"&gt;v_UpdateContents&lt;/font&gt;] view to get the Content_ID &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;font face="Consolas"&gt;Content_ID&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;Sourced from the [&lt;font face="Consolas"&gt;CI_ContentFiles&lt;/font&gt;] view joined using the Content_ID &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The information returned from this query is key to our automated patch authorization tools because it provides ConfigMgr’s Software Update feature with all the information it needs to programmatically authorize and download the necessary files for the security updates.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Update Assignments authorize security updates using the &lt;font face="Consolas"&gt;CI_ID&lt;/font&gt; field&lt;/p&gt;    &lt;p&gt;Update file download URLs come from the &lt;font face="Consolas"&gt;Content_ID &lt;/font&gt;field and get downloaded to folders with a name equal to the &lt;font face="Consolas"&gt;CI_UniqueID&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;The downloaded update file path is used as a parameter, along with the &lt;font face="Consolas"&gt;Content_ID, &lt;/font&gt;by the &lt;font face="Consolas"&gt;AddUpdateContent()&lt;/font&gt; method from the WMI object [&lt;font face="Consolas"&gt;SMS_SoftwareUpdatesPackage&lt;/font&gt;] when adding security updates to a deployment package&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Filtering updates in SQL prior to authorization also helps cut down on the number of CIs we need to process, download and replicate around the network.&amp;#160; &lt;/p&gt;  &lt;p&gt;Here are the results from a recent run of the filtering query:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/image_0E1490EF.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;float:none;padding-top:0px;padding-left:0px;margin-left:auto;border-left:0px;display:block;padding-right:0px;margin-right:auto;" border="0" alt="image" src="http://myitforum.com/cs2/blogs/jeremyyoung/image_thumb_450E6F28.png" width="403" height="105" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;So, out of the 4,214 update CI rows spanning 700 security bulletins in the database we only require 731 CIs to deploy the 92 required security updates applicable to our Datacenter.&lt;/p&gt;  &lt;p&gt;The ConfigMgr console abstracts the translation of security bulletins to their many CIs; as mentioned in a previous blog post (&lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/01/06/the-configmgr-smsprov-log-is-a-programmer-s-best-friend.aspx" target="_blank"&gt;link&lt;/a&gt;) I used the SMS_Provider.log to discover the data queries being used and then replicate the console functionality in our automation tools.&lt;/p&gt;  &lt;p&gt;Enjoy.&lt;/p&gt;  &lt;p&gt;Download &lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/ConfigMgr_FilteredSoftwareUpdates.zip" target="_blank"&gt;link&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://myitforum.com/cs2/aggbug.aspx?PostID=161201" width="1" height="1"&gt;</description><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/SQL/default.aspx">SQL</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/SCCM/default.aspx">SCCM</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/ConfigMgr/default.aspx">ConfigMgr</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Patch+Management/default.aspx">Patch Management</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/DataCenter/default.aspx">DataCenter</category></item><item><title>PowerShell Script to Check ConfigMgr Agent Software Update Assignment Compliance</title><link>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/03/29/powershell-script-to-check-configmgr-agent-software-update-compliance.aspx</link><pubDate>Thu, 29 Mar 2012 14:32:48 GMT</pubDate><guid isPermaLink="false">8e8f7986-475c-475d-bdc9-a1b3a63b955b:160892</guid><dc:creator>JeremyYoung</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://myitforum.com/cs2/blogs/jeremyyoung/rsscomments.aspx?PostID=160892</wfw:commentRss><comments>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/03/29/powershell-script-to-check-configmgr-agent-software-update-compliance.aspx#comments</comments><description>&lt;p&gt;Here is a PowerShell script to check a ConfigMgr agent’s compliance for all required/assigned security updates.&amp;#160; It is another utility tool in the kit for on-demand patch management, like this &lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/02/28/powershell-script-to-run-configmgr-task-sequence-on-demand.aspx" target="_blank"&gt;script to run a ConfigMgr Task Sequence On-Demand&lt;/a&gt;, which I blogged about previously.&amp;#160; Before you launch an on-demand patching session against a machine you should make sure it actually needs some updates, likewise, after patching you want to make sure the machine is compliant; this script addresses both scenarios.&lt;/p&gt;  &lt;p&gt;The script first checks if there is a software update assignment targeted at the machine using the WMI class &lt;em&gt;CCM_AssignmentCompliance &lt;/em&gt;from the namespace &lt;em&gt;root\ccm\SoftwareUpdates\DeploymentAgent&lt;/em&gt;.&amp;#160; If an assignment is found the script queries the WMI class &lt;em&gt;CCM_TargetedUpdateEX1 &lt;/em&gt;under the &lt;em&gt;root\ccm\SoftwareUpdates\DeploymentAgent &lt;/em&gt;namespace, which contains the mandatory updates assigned to the machine.&amp;#160; If any missing required updates are found they will be returned as output. &lt;/p&gt;  &lt;p&gt;Running this script on a machine before patching you would see something similar to this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/image_6E60347C.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="http://myitforum.com/cs2/blogs/jeremyyoung/image_thumb_1BD12E73.png" width="501" height="47" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And after patching you would expect to see:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/image_540FA58B.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="http://myitforum.com/cs2/blogs/jeremyyoung/image_thumb_13D98C11.png" width="503" height="29" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;See the script comments for the exact syntax:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/image_3879C5DC.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="http://myitforum.com/cs2/blogs/jeremyyoung/image_thumb_6D1A2217.png" width="406" height="51" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Enjoy.&lt;/p&gt;  &lt;p&gt;Download &lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/Get-ConfigMgrSoftwareUpdateCompliance.zip" target="_blank"&gt;Link&lt;/a&gt;&lt;/p&gt;&lt;img src="http://myitforum.com/cs2/aggbug.aspx?PostID=160892" width="1" height="1"&gt;</description><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/SCCM/default.aspx">SCCM</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/ConfigMgr/default.aspx">ConfigMgr</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Patch+Management/default.aspx">Patch Management</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/DataCenter/default.aspx">DataCenter</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/PowerShell/default.aspx">PowerShell</category></item><item><title>Powershell Script to Run ConfigMgr Task Sequence On-Demand</title><link>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/02/28/powershell-script-to-run-configmgr-task-sequence-on-demand.aspx</link><pubDate>Wed, 29 Feb 2012 06:42:00 GMT</pubDate><guid isPermaLink="false">8e8f7986-475c-475d-bdc9-a1b3a63b955b:160740</guid><dc:creator>JeremyYoung</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://myitforum.com/cs2/blogs/jeremyyoung/rsscomments.aspx?PostID=160740</wfw:commentRss><comments>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2012/02/28/powershell-script-to-run-configmgr-task-sequence-on-demand.aspx#comments</comments><description>&lt;p&gt;I wrote a script to handle a cluster patching situation where I needed to give a server owner the ability to run the ConfigMgr &lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2011/11/23/sccm-patch-management-using-the-task-sequence-engine.aspx" target="_blank"&gt;monthly patch management task sequence&lt;/a&gt; on-demand (immediately) via PowerShell.&amp;nbsp; The server owner would use another script to make their machine, in this case a cluster joined virtual server host, ready for patching (resources drained, removed from the cluster, etc.) and then initiate the patch task sequence to install any required security updates. At the end of the task sequence a post-patching script will make the server ready for production (rejoin the cluster) so they can continue onto the next host programatically, rinse, repeat, through the rest of the clustered hosts.&lt;/p&gt;
&lt;p&gt;The script takes a parameter for the machine name (else it will default to the local machine) and also the name of the ConfigMgr task sequence to be run.&amp;nbsp; The task sequence must already be advertised to the machine for this script to work because it searches the local WMI repository for the task sequence name and then works backwards to determine a policy ID to trigger.&amp;nbsp; Once the policy ID is found it uses the SMS_Client::TriggerSchedule method to execute the task sequence immediately.&lt;/p&gt;
&lt;p&gt;If you need to target a machine but only make the task sequence available on-demand you can set up an advertisement with a mandatory schedule way out in the future, basically something that will never run but the necessary policy objects still get created in the local WMI repository to run on-demand.&lt;/p&gt;
&lt;p&gt;See the script comments for the syntax.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/image_0CCD5AD7.png"&gt;&lt;img style="BACKGROUND-IMAGE:none;BORDER-BOTTOM:0px;BORDER-LEFT:0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP:0px;BORDER-RIGHT:0px;PADDING-TOP:0px;" title="image" border="0" alt="image" src="http://myitforum.com/cs2/blogs/jeremyyoung/image_thumb_0541EB6A.png" width="510" height="36" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Hope you enjoy!&lt;/p&gt;
&lt;p&gt;Download &lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/Invoke-ConfigMgrTaskSequence.zip" target="_blank"&gt;Link&lt;/a&gt;&lt;/p&gt;&lt;img src="http://myitforum.com/cs2/aggbug.aspx?PostID=160740" width="1" height="1"&gt;</description><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/SCCM/default.aspx">SCCM</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/ConfigMgr/default.aspx">ConfigMgr</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Patch+Management/default.aspx">Patch Management</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/DataCenter/default.aspx">DataCenter</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Task+Sequence/default.aspx">Task Sequence</category></item><item><title>SCCM Patch Management Using The Task Sequence Engine</title><link>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2011/11/23/sccm-patch-management-using-the-task-sequence-engine.aspx</link><pubDate>Thu, 24 Nov 2011 02:04:00 GMT</pubDate><guid isPermaLink="false">8e8f7986-475c-475d-bdc9-a1b3a63b955b:160257</guid><dc:creator>JeremyYoung</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://myitforum.com/cs2/blogs/jeremyyoung/rsscomments.aspx?PostID=160257</wfw:commentRss><comments>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2011/11/23/sccm-patch-management-using-the-task-sequence-engine.aspx#comments</comments><description>&lt;p&gt;As I mentioned in a previous blog &lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2011/10/26/Using-PowerShell-to-Manage-SCCM-Collection-Variables.aspx" target="_blank"&gt;post&lt;/a&gt;, we recently switched our monthly patch management function via SCCM away from the built-in Software Update Management (SUM) feature to the Task Sequence Engine.&lt;/p&gt;
&lt;p&gt;One of the primary drivers behind making the technology shift was the increasing frequency at which we were deploying software (applications, non-security updates, etc.) inside the same maintenance windows used for software updates.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Without the task sequence engine there is no easy way to coordinate when the software installs and patching would happen; we had started scheduling software during the second half of the two hour maintenance windows but as the distinct software distributions started stacking up keeping up with the install schedules became increasingly difficult.&lt;/p&gt;
&lt;p&gt;The other benefits of this change should become clear after I explain the steps/groups inside of the task sequence.&lt;/p&gt;
&lt;p&gt;Here is a simplified example of what our monthly patch management task sequence looks like:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/image_1128B8AB.png"&gt;&lt;img style="BACKGROUND-IMAGE:none;BORDER-BOTTOM:0px;BORDER-LEFT:0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;FLOAT:left;BORDER-TOP:0px;BORDER-RIGHT:0px;PADDING-TOP:0px;" title="image" border="0" alt="image" align="left" src="http://myitforum.com/cs2/blogs/jeremyyoung/image_thumb_0526C877.png" width="235" height="434" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;&lt;u&gt;Inject Random Sleep:&lt;/u&gt; &lt;/font&gt;&lt;/strong&gt;&lt;font size="2"&gt;A simple random sleep timer to spread out the execution of the task sequence.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;u&gt;Pre-Patch Custom Actions:&lt;/u&gt;&lt;/strong&gt; This step runs any custom actions to make a server ready for patching, stopping services, failing over resources, etc.. These custom scripts are provided by the machine owners and assigned to the machine via collection variables.&amp;nbsp; This is one of the only steps where we do not set the “Continue on Error” option so that if a machine fails to be made ready for patching we have an opportunity to stop processing further steps.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;u&gt;Install Required Software Updates:&lt;/u&gt;&lt;/strong&gt; The heart of the task sequence; this step installs all of the mandatory security updates targeted at a machine. Prior to patching the machine will also be rebooted if any pending reboot operations are detected.&amp;nbsp; Following the patch installs we run our Update Install Source script to gather data about “who” installed the security updates (see this previous blog &lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2011/09/30/update-install-source.aspx" target="_blank"&gt;post&lt;/a&gt; for more information).&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;u&gt;Install Required Non-Security Updates:&lt;/u&gt;&lt;/strong&gt; This step allows us to install any QFE’s/Hotfixes that are required. Since we would not want to reboot after each update we declare a variable to detect if a reboot was required.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;u&gt;Install Required Software Distributions:&lt;/u&gt;&lt;/strong&gt; Install or modify any required software distributions that are relevant to the machine.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;u&gt;Agent Maintenance:&lt;/u&gt;&lt;/strong&gt; This step allows us to perform upgrades or maintenance on our core agents, SCCM, WindowsUpdate, OpsMgr, FEP.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;&lt;u&gt;Post-Patch Custom Actions:&lt;/u&gt;&lt;/strong&gt; The clean-up phase of the task sequence.; this step runs any server owner provided custom action scripts to make a server ready for production again post patching, starting services, reclaiming resources, monthly maintenance steps (log archiving for example).&amp;nbsp; We also handle any pending reboot operations that may have been caused by agent maintenance, software distributions, or non-security updates installed during the task sequence execution.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Switching to patching via the task sequence is not without its challenges; it requires some major changes in the way that you target machines, configure update policies and maintenance windows.&lt;/p&gt;
&lt;p&gt;Here are some key lessons learned from our implementation (so far):&lt;/p&gt;
&lt;p&gt;&lt;u&gt;SCCM Advertisements&lt;/u&gt;:&lt;/p&gt;
&lt;p&gt;If you use the SCCM native SUM feature you can get by on collection level maintenance windows alone to control when updates are installed.&amp;nbsp; I found out in testing that you can’t control the execution order of generic task sequences and SUM deployments; only OSD task sequence types get a special maintenance window override flag. When we tried to use collection maintenance windows to advertise the task sequence the SUM feature would start separately at the same time and then reboot the machine causing the task sequence to fail.&amp;nbsp; The SCCM advertisements will deliver the task sequence and also provide the bounds for the the maintenance window, using a combination of Mandatory Time and Expire Time, instead of the collection level maintenance windows.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;Past Deadline SUM Deployment Policy&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;We need agents to install, not just be offered, any mandatory updates during the maintenance window.&amp;nbsp; Also, machines will only pre-download the required update files before the maintenance window if the policy is past deadline.&amp;nbsp; The policy is configured to only run during maintenance windows and prevent system reboots outside of maintenance windows.&lt;/p&gt;
&lt;ul&gt;
&lt;ul&gt;&lt;/ul&gt;&lt;/ul&gt;
&lt;p&gt;&lt;u&gt;Prevention Maintenance Window&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;A “dummy” maintenance window for all agents set to some date in the future which will prevent machines from running the past deadline SUM Deployment Policy outside of their actual maintenance window.&amp;nbsp; Caution: this maintenance window will prevent all machines from running any software distribution, unless override maintenance windows option is selected on the advertisement.&amp;nbsp; *Important Safety Tip* set this prevention date far enough in the future that you will not likely ever reach it; or at least until you expect to leave your role and it’s someone else’s problem ;)&lt;/p&gt;
&lt;p&gt;&lt;u&gt;Automation&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;We manage a large and dynamic population of servers and we offer choices of ~42 different maintenance windows (6 per day x 7 days).&amp;nbsp; Servers can move maintenance windows at will and some machines receive patching extensions that have to be kept out of all targeted collections; maintaining these manually is not an option.&amp;nbsp; I wrote some PowerShell tools that handle the translation of selected maintenance windows in a CMDB –&amp;gt; SCCM collections/advertisements; maybe a future blog topic.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;Variables (Collection/Task Sequence) for Orchestration Control&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;Use collection variables and task sequence variables as program flow gateways for steps/groups inside the task sequence.&amp;nbsp; Variables offer a simple way to assign programs to machines or even multiple programs using base variables. Variables can also collect execution return codes to postpone reboots or to send machines down a different set of steps/groups.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Looking for a good way to manage collection variables?&amp;nbsp; Refer to my PowerShell library blog &lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/archive/2011/10/26/Using-PowerShell-to-Manage-SCCM-Collection-Variables.aspx" target="_blank"&gt;post&lt;/a&gt; about it.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;Program Exit Code / Reboot Control&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;There aren’t many options available for controlling the task sequence reboot behavior at each step; any program that returns the universal 3010 code will cause the Task Sequence Engine to reboot the machine immediately after the step completes.&amp;nbsp; I learned this lesson the hard way when we lined up five QFE/Hotfix installs and machines rebooted after each one.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;It’s best to use a simple wrapper script to call the software installer and then manage the return code to mark a variable for reboot required and then pass back a 0 (success) return code.&amp;nbsp; Also beware of native program return codes that map to irrelevant SCCM status messages – after a bit of pointless troubleshooting I learned that a QFE returned a WSUS exit code that equated to “Update Not Required” but the error message in ExecMgr.log said something like “File Not Found”.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;Status Message Increase&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;Prepare for an increase in status messages during patching windows, especially as you add steps/groups into the task sequence.&amp;nbsp; Agents will send status messages (sometimes multiple) for each step/group they process.&amp;nbsp; While this yields a new level of detail for your reporting it also increases the load on the infrastructure/network during patching windows.&lt;/p&gt;
&lt;p&gt;Hopefully I’ve sparked your interest in switching to the Task Sequence Engine for patch management; while it definitely adds an extra layer (or two!) of complication the benefits gained in orchestration, reporting and general extensibility (to name a few) make it worth the investment...&lt;/p&gt;&lt;img src="http://myitforum.com/cs2/aggbug.aspx?PostID=160257" width="1" height="1"&gt;</description><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/SCCM/default.aspx">SCCM</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/ConfigMgr/default.aspx">ConfigMgr</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Patch+Management/default.aspx">Patch Management</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/DataCenter/default.aspx">DataCenter</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Task+Sequence/default.aspx">Task Sequence</category></item><item><title>Update Install Source</title><link>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2011/09/30/update-install-source.aspx</link><pubDate>Fri, 30 Sep 2011 19:57:00 GMT</pubDate><guid isPermaLink="false">8e8f7986-475c-475d-bdc9-a1b3a63b955b:159645</guid><dc:creator>JeremyYoung</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://myitforum.com/cs2/blogs/jeremyyoung/rsscomments.aspx?PostID=159645</wfw:commentRss><comments>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2011/09/30/update-install-source.aspx#comments</comments><description>&lt;p&gt;Inside the Microsoft IT Datacenter environment SCCM is the main tool used for automated patch management.&amp;#160; Some servers are still manually patched by their server owners using many different tools (scripts, WSUS, AutomaticUpdates, download/install the exe’s manually, etc.).&amp;#160; Since our primary focus is on the security of the environment it doesn’t &lt;em&gt;really&lt;/em&gt; matter how servers get secured each month for the required updates.&amp;#160; &lt;/p&gt;  &lt;p&gt;However, in order to measure the usage of our automated patching service we wanted to see how many of these servers are actually getting updates installed by SCCM versus those being manually patched.&lt;/p&gt;  &lt;p&gt;You would think this data would exist in the SCCM database…&amp;#160; &lt;/p&gt;  &lt;p&gt;SCCM does have a column that looks like it contains the install source information; the column is &lt;em&gt;EnforcementSource&lt;/em&gt; in the view &lt;em&gt;v_UpdateComplianceStatus&lt;/em&gt; (and a few other views too).&amp;#160; &lt;/p&gt;  &lt;p&gt;The column is an integer type and the WMI class definition shows the possible values as follows: &lt;/p&gt;  &lt;p&gt;&lt;a title="SMS_CI_CurrentComplianceStatus Server WMI Class" href="http://msdn.microsoft.com/en-us/library/cc143995.aspx" target="_blank"&gt;&lt;u&gt;SMS_CI_CurrentComplianceStatus Server WMI Class&lt;/u&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/image_6AD0E950.png"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://myitforum.com/cs2/blogs/jeremyyoung/image_thumb_1132CC9C.png" width="244" height="182" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After comparing the data for machines I manually updated and machines where I let SCCM install the updates I found that this view did not provide the results I was expecting; both sets of machines showed &lt;em&gt;EnforcementSource&lt;/em&gt; = 2 == USER.&amp;#160; After more research, testing and chats with colleagues, it appears these values are tied to the mandatory enforcement messages and not necessarily the mechanism that installed the update; else it’s bad data being returned to SCCM…&lt;/p&gt;  &lt;p&gt;I talked with another Microsoft colleague, Satish Petwe, who works on the SCCM team managing a large population of desktop clients, and he had found that update install source data does exist on the machine in the local Windows Update agent repository.&lt;/p&gt;  &lt;p&gt;Executing the &lt;a href="http://msdn.microsoft.com/en-us/library/aa386532(v=VS.85).aspx" target="_blank"&gt;QueryHistory&lt;/a&gt; method inside the &lt;a href="http://msdn.microsoft.com/en-us/library/aa386515.aspx" target="_blank"&gt;&lt;em&gt;Microsoft.Update.Searcher&lt;/em&gt;&lt;/a&gt;&lt;em&gt;&amp;#160;&lt;/em&gt;object will return a list of updates applicable to the machine.&amp;#160; The list can be filtered to show only the installed updates and most importantly the result object contains a property called &lt;em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa386420.aspx" target="_blank"&gt;ClientApplicationID&lt;/a&gt; &lt;/em&gt;which stores the application that processed the update.&lt;/p&gt;  &lt;p&gt;As you can see in the output generated by the vbscript (code at the bottom of the page) this is exactly the information I was looking for:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://myitforum.com/cs2/blogs/jeremyyoung/image_78C52D1C.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://myitforum.com/cs2/blogs/jeremyyoung/image_thumb_77ECC732.png" width="507" height="145" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You could also use this data to see the different non-SCCM applications that are being used to install updates in your environment, but as I stated earlier true install counts by SCCM was our main goal.&lt;/p&gt;  &lt;p&gt;There are a number of options on how to get this data back to a central location; I decided on funneling the relevant information into a local WMI class and then extending SCCM inventory to bring it back to the central site database. I haven’t done further investigation to see if this information is available in WSUS natively; I assume we would have to enable WSUS reporting events on our Software Update Points.&lt;/p&gt;  &lt;p&gt;Here’s some quick vbscript code just to give you an idea how to find the data.&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;Set&lt;/span&gt; loc = CreateObject(&lt;span style="color:#006080;"&gt;&amp;quot;WbemScripting.SWbemLocator&amp;quot;&lt;/span&gt;) &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;Set&lt;/span&gt; WbemServices = loc.ConnectServer(, &lt;span style="color:#006080;"&gt;&amp;quot;root\cimv2&amp;quot;&lt;/span&gt;)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;On&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Error&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Resume&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Next&lt;/span&gt; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;Set&lt;/span&gt; oWU = CreateObject(&lt;span style="color:#006080;"&gt;&amp;quot;Microsoft.Update.Searcher&amp;quot;&lt;/span&gt;) &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;iTHCount = oWU.GetTotalHistoryCount &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;&amp;#39;make sure there is something returned from the WU searcher &lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;If&lt;/span&gt; iTHCount &amp;gt; 0 &lt;span style="color:#0000ff;"&gt;Then&lt;/span&gt; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39;query the WU history to get all the updates on this machine &lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;Set&lt;/span&gt; colUpdate = oWU.QueryHistory(0, iTHCount) &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;For&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Each&lt;/span&gt; oUpdate &lt;span style="color:#0000ff;"&gt;In&lt;/span&gt; colUpdate     &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;        &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#008000;"&gt;&amp;#39;only look for successfully installed updates ResultCode=2 &lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;If&lt;/span&gt;  oUpdate.ResultCode = 2 &lt;span style="color:#0000ff;"&gt;then&lt;/span&gt; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;     UpdateID =oUpdate.UpdateIdentity.UpdateID    &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;     Title=oUpdate.Title &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;     DateGMT=oUpdate.&lt;span style="color:#0000ff;"&gt;Date&lt;/span&gt; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;     InstallAgent=oUpdate.ClientApplicationID     &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;     &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    wscript.echo Title &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    wscript.echo &lt;span style="color:#006080;"&gt;&amp;quot;     UpdateGUID: [&amp;quot;&lt;/span&gt; &amp;amp; UpdateID &amp;amp; &lt;span style="color:#006080;"&gt;&amp;quot;]&amp;quot;&lt;/span&gt; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    wscript.echo &lt;span style="color:#006080;"&gt;&amp;quot;     Installed by: &amp;quot;&lt;/span&gt; &amp;amp; InstallAgent &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    wscript.echo &lt;span style="color:#006080;"&gt;&amp;quot;     Installed on: [&amp;quot;&lt;/span&gt; &amp;amp; DateGMT &amp;amp; &lt;span style="color:#006080;"&gt;&amp;quot;]&amp;quot;&lt;/span&gt; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;     &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;  &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;Next&lt;/span&gt; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:white;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;If&lt;/span&gt; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;img src="http://myitforum.com/cs2/aggbug.aspx?PostID=159645" width="1" height="1"&gt;</description><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/SCCM/default.aspx">SCCM</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/ConfigMgr/default.aspx">ConfigMgr</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Patch+Management/default.aspx">Patch Management</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/DataCenter/default.aspx">DataCenter</category></item><item><title>Finding the Patch Cycle Location Using SQL</title><link>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2011/08/23/Finding-Patch-Cycle-Location-Using-SQL.aspx</link><pubDate>Tue, 23 Aug 2011 23:11:00 GMT</pubDate><guid isPermaLink="false">8e8f7986-475c-475d-bdc9-a1b3a63b955b:159044</guid><dc:creator>JeremyYoung</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://myitforum.com/cs2/blogs/jeremyyoung/rsscomments.aspx?PostID=159044</wfw:commentRss><comments>http://myitforum.com/cs2/blogs/jeremyyoung/archive/2011/08/23/Finding-Patch-Cycle-Location-Using-SQL.aspx#comments</comments><description>&lt;p&gt;Inside Microsoft IT the monthly security patch cycles for our Datacenter servers are static; over the years the deadline lengths have changed and some phases have shifted around but it always remains highly predictable.&lt;/p&gt;
&lt;p&gt;At a high level each patch cycles consists of the following phases:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;u&gt;Patch Tuesday Release &lt;/u&gt;:: Start of a new patching cycle. &lt;/li&gt;
&lt;li&gt;&lt;u&gt;Patch Deployment Preparation&lt;/u&gt; :: Authorizing updates, downloading and sending bits to SCCM distribution points, WSUS, preparing collections for deployments, etc. &lt;/li&gt;
&lt;li&gt;&lt;u&gt;Pre-Production Patching&lt;/u&gt; :: Smoke test of the patch content and deployment setup to pre-production machines. &lt;/li&gt;
&lt;li&gt;&lt;u&gt;Production Patching&lt;/u&gt; :: Main patching deployment to all production machines. &lt;/li&gt;&lt;/ul&gt;&lt;/blockquote&gt;
&lt;p&gt;Have you ever looked at a compliance report and wondered which part of the security patch cycle the results belonged to? Or thought to yourself, “is this a patching weekend?” Given that each patch cycle is predictable I wrote a bit of SQL code to take a date, apply the patch cycle business logic and return the patch cycle location.&lt;/p&gt;
&lt;p&gt;The first step is to calculate the first day of the month of the date provided; in this case @Date is set to the current date.&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;declare&lt;/span&gt; @&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt; datetime = getdate()&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;declare&lt;/span&gt; @FirstDayofCurrentMonth &lt;span style="COLOR:#0000ff;"&gt;date&lt;/span&gt; = DATEADD(dd,-(&lt;span style="COLOR:#0000ff;"&gt;DAY&lt;/span&gt;(@&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt;)-1),@&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt;)&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Next comes the most important bit of code which will find the date for Patch Tuesday. Patch Tuesday occurs on the 2nd Tuesday of each month. Initially I was taking the long route to calculate this date, but luckily I stumbled upon this &lt;a href="http://www.devarticles.com/c/a/SQL/Generating-Reports-with-SQL-Date-Handling/3/"&gt;article&lt;/a&gt; which showed a much cleaner formula for finding the second Tuesday of the month (read the article for the details):&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;set&lt;/span&gt; @PatchTues = DATEADD(&lt;span style="COLOR:#0000ff;"&gt;day&lt;/span&gt;,((10 - &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;        DATEPART(dw,@FirstDayofCurrentMonth)) % 7) &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;        + 7, @FirstDayofCurrentMonth)&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Patch cycles span from Patch Tuesday to the next Patch Tuesday, so after a date for Patch Tuesday is found, an additional check must be done to see if the @Date variable is less than the calculated Patch Tuesday date; for example, if @Date equals the first day of a month you are still within the previous patch cycle; in this case recalculate Patch Tuesday based on the first day of the previous month:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;if&lt;/span&gt;(@&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt; &amp;lt; @PatchTues)&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;begin&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- get the first day of last month&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;declare&lt;/span&gt; @FirstDayofLastMonth &lt;span style="COLOR:#0000ff;"&gt;date&lt;/span&gt; = DATEADD(dd,&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    -(&lt;span style="COLOR:#0000ff;"&gt;DAY&lt;/span&gt;(DATEADD(mm,1,@&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt;))-1),DATEADD(mm,-1,@&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt;))&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- calculate previous patch tues from first day last month&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;set&lt;/span&gt; @PatchTues = DATEADD(&lt;span style="COLOR:#0000ff;"&gt;day&lt;/span&gt;,((10 -&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    DATEPART(dw,@FirstDayofLastMonth)) % 7)&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;     + 7, @FirstDayofLastMonth)        &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;/div&gt;
&lt;p&gt;Now that the correct Patch Tuesday date has been found the rest of the code calculates the number of days from Patch Tuesday and applies the logic to determine the phase of the patch cycle:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;-- find out how many days from current patch tues&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;declare&lt;/span&gt; @DaysFromCurrentPatchTues &lt;span style="COLOR:#0000ff;"&gt;int&lt;/span&gt; = DATEDIFF(&lt;span style="COLOR:#0000ff;"&gt;day&lt;/span&gt;,@PatchTues,@&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt;)&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;/div&gt;
&lt;p&gt;And then use a case statement to assign the Patch Cycle location to a variable; our current patching cycle is 19 days long:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;set&lt;/span&gt; @idPatchCycleLocation = &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;case&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- patch tuesday&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;when&lt;/span&gt; @DaysFromCurrentPatchTues = 0 &lt;span style="COLOR:#0000ff;"&gt;then&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;&amp;#39;Patch Tuesday&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- days 1 and 2 are for patch prep&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;when&lt;/span&gt; @DaysFromCurrentPatchTues &lt;span style="COLOR:#0000ff;"&gt;between&lt;/span&gt; 1 &lt;span style="COLOR:#0000ff;"&gt;and&lt;/span&gt; 2 &lt;span style="COLOR:#0000ff;"&gt;then&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;&amp;#39;DeploymentPrep&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- days 3-5 are for smoke test patching (dev/test systems)            &lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;when&lt;/span&gt; @DaysFromCurrentPatchTues &lt;span style="COLOR:#0000ff;"&gt;between&lt;/span&gt; 3 &lt;span style="COLOR:#0000ff;"&gt;and&lt;/span&gt; 5 &lt;span style="COLOR:#0000ff;"&gt;then&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;&amp;#39;PreProductionPatching&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- days 6 thru 12 are maintenance window patching&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;when&lt;/span&gt; @DaysFromCurrentPatchTues &lt;span style="COLOR:#0000ff;"&gt;between&lt;/span&gt; 6 &lt;span style="COLOR:#0000ff;"&gt;and&lt;/span&gt; 19 &lt;span style="COLOR:#0000ff;"&gt;then&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;&amp;#39;ProductionPatching&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- anything over 19 is inbetween cycles&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;when&lt;/span&gt; @DaysFromCurrentPatchTues &amp;gt; 19 &lt;span style="COLOR:#0000ff;"&gt;then&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;&amp;#39;InBetweenCycles&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;end&lt;/span&gt;    &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;&lt;/div&gt;
&lt;p&gt;The last step is to return the Patch Cycle location with key data about the patch month/cycle:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;-- return the patch cycle location&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;select&lt;/span&gt; &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- use the calculated patch tuesday&amp;#39;s month/year&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    DATENAME(&lt;span style="COLOR:#0000ff;"&gt;month&lt;/span&gt;,@PatchTues) &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; PatchMonth  &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    ,&lt;span style="COLOR:#0000ff;"&gt;YEAR&lt;/span&gt;(@PatchTues) &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; PatchYear&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    ,&lt;span style="COLOR:#0000ff;"&gt;Convert&lt;/span&gt;(&lt;span style="COLOR:#0000ff;"&gt;varchar&lt;/span&gt;(25),DATENAME(&lt;span style="COLOR:#0000ff;"&gt;month&lt;/span&gt;,@PatchTues)) &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;        + &lt;span style="COLOR:#006080;"&gt;&amp;#39; &amp;#39;&lt;/span&gt; + &lt;span style="COLOR:#0000ff;"&gt;Convert&lt;/span&gt;(&lt;span style="COLOR:#0000ff;"&gt;varchar&lt;/span&gt;(25),&lt;span style="COLOR:#0000ff;"&gt;YEAR&lt;/span&gt;(@PatchTues)) &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; PatchCycle&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    ,@idPatchCycleLocation &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; PatchCycleLocation&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The output will look like this:&lt;/p&gt;
&lt;table cellspacing="0" cellpadding="2"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;PatchMonth&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;PatchYear&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;PatchCycle&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;PatchCycleLocation&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;August&lt;/td&gt;
&lt;td&gt;2011&lt;/td&gt;
&lt;td&gt;August 2011&lt;/td&gt;
&lt;td&gt;ProductionPatching&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;div align="center"&gt;&lt;/div&gt;
&lt;p&gt;In our production environment, this code has been wrapped into a SQL user-defined function with a parameter for the date so that it can be easily joined it to other SQL data. &lt;/p&gt;
&lt;p&gt;Using SQL to find the Patch Cycle location adds extra value to reports, especially patch compliance reports where data can now be broken down by patch cycle phases. I also built an SRS report object that uses this function to build a dynamic monthly patching calendar to share with our server owners.&lt;/p&gt;
&lt;p&gt;In addition to reporting integration this function is also used to drive automation into the monthly SCCM patch management administration tasks. Our patching process allows server owners to select a maintenance window for SCCM to patch their servers; the maintenance window choices are generic, i.e. “Saturday 12:00 AM – 2:00 AM” but as you saw from our business logic there are only specific weeks of the month where patching might be active.&amp;nbsp; Using this patch cycle location code makes it possible to map a generic date to an actual date during the right patch cycle phase and drive the automation scripts to place the servers into the right collections for SCCM patching.&lt;/p&gt;
&lt;p&gt;Here is the full SQL code; I hope you enjoy it!&lt;/p&gt;
&lt;p&gt;Please share any other uses you find for this code!&lt;/p&gt;
&lt;p&gt;Thanks for reading my first blog post.&lt;/p&gt;
&lt;div style="BORDER-BOTTOM:silver 1px solid;TEXT-ALIGN:left;BORDER-LEFT:silver 1px solid;PADDING-BOTTOM:4px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:20px 0px 10px;PADDING-LEFT:4px;WIDTH:97.5%;PADDING-RIGHT:4px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;MAX-HEIGHT:200px;FONT-SIZE:8pt;OVERFLOW:auto;BORDER-TOP:silver 1px solid;CURSOR:text;BORDER-RIGHT:silver 1px solid;PADDING-TOP:4px;" id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;declare&lt;/span&gt; @&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt; datetime = getdate()&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;declare&lt;/span&gt; @PatchTues &lt;span style="COLOR:#0000ff;"&gt;date&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;declare&lt;/span&gt; @idPatchCycleLocation &lt;span style="COLOR:#0000ff;"&gt;varchar&lt;/span&gt;(25)&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;     &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;-- using the date provided calculate the first day of the month&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;declare&lt;/span&gt; @FirstDayofCurrentMonth &lt;span style="COLOR:#0000ff;"&gt;date&lt;/span&gt; = DATEADD(dd,-(&lt;span style="COLOR:#0000ff;"&gt;DAY&lt;/span&gt;(@&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt;)-1),@&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt; &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;/*&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;    patch tuesday is 2nd tues of each month; use the first day of the month to calculate it&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;    &lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;    based on formula found at:&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;    http://www.devarticles.com/c/a/SQL/Generating-Reports-with-SQL-Date-Handling/3/&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;    &lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;*/&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;set&lt;/span&gt; @PatchTues = DATEADD(&lt;span style="COLOR:#0000ff;"&gt;day&lt;/span&gt;,((10 - DATEPART(dw,@FirstDayofCurrentMonth)) % 7) + 7, @FirstDayofCurrentMonth)&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt; &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;/*&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;    check if the current date is less patch tues date &lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;    if so recalculate based on last month, i.e. the month rolled over&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;*/&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;if&lt;/span&gt;(@&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt; &amp;lt; @PatchTues)&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;begin&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- get the first day of last month&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;declare&lt;/span&gt; @FirstDayofLastMonth &lt;span style="COLOR:#0000ff;"&gt;date&lt;/span&gt; = DATEADD(dd,-(&lt;span style="COLOR:#0000ff;"&gt;DAY&lt;/span&gt;(DATEADD(mm,1,@&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt;))-1),DATEADD(mm,-1,@&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt;))&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;        &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- calculate previous patch tues from first day last month&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;set&lt;/span&gt; @PatchTues = DATEADD(&lt;span style="COLOR:#0000ff;"&gt;day&lt;/span&gt;,((10 - DATEPART(dw,@FirstDayofLastMonth)) % 7) + 7, @FirstDayofLastMonth)        &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;   &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt; &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;-- find out how many days from current patch tues&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;declare&lt;/span&gt; @DaysFromCurrentPatchTues &lt;span style="COLOR:#0000ff;"&gt;int&lt;/span&gt; = DATEDIFF(&lt;span style="COLOR:#0000ff;"&gt;day&lt;/span&gt;,@PatchTues,@&lt;span style="COLOR:#0000ff;"&gt;Date&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt; &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;set&lt;/span&gt; @idPatchCycleLocation = &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;case&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- patch tuesday&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;when&lt;/span&gt; @DaysFromCurrentPatchTues = 0 &lt;span style="COLOR:#0000ff;"&gt;then&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;&amp;#39;Patch Tuesday&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- days 1 and 2 are for patch prep&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;when&lt;/span&gt; @DaysFromCurrentPatchTues &lt;span style="COLOR:#0000ff;"&gt;between&lt;/span&gt; 1 &lt;span style="COLOR:#0000ff;"&gt;and&lt;/span&gt; 2 &lt;span style="COLOR:#0000ff;"&gt;then&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;&amp;#39;DeploymentPrep&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- days 3-5 are for smoke test patching (dev/test systems)            &lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;when&lt;/span&gt; @DaysFromCurrentPatchTues &lt;span style="COLOR:#0000ff;"&gt;between&lt;/span&gt; 3 &lt;span style="COLOR:#0000ff;"&gt;and&lt;/span&gt; 5 &lt;span style="COLOR:#0000ff;"&gt;then&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;&amp;#39;PreProductionPatching&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- days 6 thru 12 are maintenance window patching&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;when&lt;/span&gt; @DaysFromCurrentPatchTues &lt;span style="COLOR:#0000ff;"&gt;between&lt;/span&gt; 6 &lt;span style="COLOR:#0000ff;"&gt;and&lt;/span&gt; 19 &lt;span style="COLOR:#0000ff;"&gt;then&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;&amp;#39;ProductionPatching&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- anything over 19 is inbetween cycles&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#0000ff;"&gt;when&lt;/span&gt; @DaysFromCurrentPatchTues &amp;gt; 19 &lt;span style="COLOR:#0000ff;"&gt;then&lt;/span&gt; &lt;span style="COLOR:#006080;"&gt;&amp;#39;InBetweenCycles&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;end&lt;/span&gt;    &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt; &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#008000;"&gt;-- return the patch cycle location&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;&lt;span style="COLOR:#0000ff;"&gt;select&lt;/span&gt; &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    &lt;span style="COLOR:#008000;"&gt;-- use the calculated patch tuesday&amp;#39;s month/year&lt;/span&gt;&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    DATENAME(&lt;span style="COLOR:#0000ff;"&gt;month&lt;/span&gt;,@PatchTues) &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; PatchMonth  &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    ,&lt;span style="COLOR:#0000ff;"&gt;YEAR&lt;/span&gt;(@PatchTues) &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; PatchYear&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    ,&lt;span style="COLOR:#0000ff;"&gt;Convert&lt;/span&gt;(&lt;span style="COLOR:#0000ff;"&gt;varchar&lt;/span&gt;(25),DATENAME(&lt;span style="COLOR:#0000ff;"&gt;month&lt;/span&gt;,@PatchTues)) &lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:white;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;        + &lt;span style="COLOR:#006080;"&gt;&amp;#39; &amp;#39;&lt;/span&gt; + &lt;span style="COLOR:#0000ff;"&gt;Convert&lt;/span&gt;(&lt;span style="COLOR:#0000ff;"&gt;varchar&lt;/span&gt;(25),&lt;span style="COLOR:#0000ff;"&gt;YEAR&lt;/span&gt;(@PatchTues)) &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; PatchCycle&lt;/pre&gt;&lt;pre style="BORDER-BOTTOM-STYLE:none;TEXT-ALIGN:left;PADDING-BOTTOM:0px;LINE-HEIGHT:12pt;BACKGROUND-COLOR:#f4f4f4;MARGIN:0em;BORDER-LEFT-STYLE:none;PADDING-LEFT:0px;WIDTH:100%;PADDING-RIGHT:0px;FONT-FAMILY:&amp;#39;Courier New&amp;#39;, courier, monospace;DIRECTION:ltr;BORDER-TOP-STYLE:none;COLOR:black;BORDER-RIGHT-STYLE:none;FONT-SIZE:8pt;OVERFLOW:visible;PADDING-TOP:0px;"&gt;    ,@idPatchCycleLocation &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; PatchCycleLocation&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src="http://myitforum.com/cs2/aggbug.aspx?PostID=159044" width="1" height="1"&gt;</description><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/SQL/default.aspx">SQL</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/SCCM/default.aspx">SCCM</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/ConfigMgr/default.aspx">ConfigMgr</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/Patch+Management/default.aspx">Patch Management</category><category domain="http://myitforum.com/cs2/blogs/jeremyyoung/archive/tags/DataCenter/default.aspx">DataCenter</category></item></channel></rss>