<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jonathan Medd&#039;s Blog &#187; wsus</title>
	<atom:link href="http://www.jonathanmedd.net/tag/wsus/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jonathanmedd.net</link>
	<description>Scripting. Powershell, VMware, Windows, Active Directory &#38; Exchange. All that kind of stuff.....</description>
	<lastBuildDate>Wed, 21 Jul 2010 12:41:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WSUS 3.0 Cleaning out redundant computers</title>
		<link>http://www.jonathanmedd.net/2008/11/wsus-30-cleaning-out-redundant-computers.html</link>
		<comments>http://www.jonathanmedd.net/2008/11/wsus-30-cleaning-out-redundant-computers.html#comments</comments>
		<pubDate>Thu, 20 Nov 2008 09:50:00 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[wsus]]></category>

		<guid isPermaLink="false">http://jonathanmedd.wordpress.com/2008/11/20/wsus-30-cleaning-out-redundant-computers/</guid>
		<description><![CDATA[Following on from my last post about WSUS 3.0 and Powershell another thing which bugged me about the WSUS 3.0 GUI is the Cleanup Wizard. This is a really useful tool for keeping your WSUS deployment running efficiently.
It includes the ability to clean out computers which haven&#8217;t synched with the WSUS server for over 30 [...]]]></description>
			<content:encoded><![CDATA[<p>Following on from my last post about <a href="http://jonathanmedd.blogspot.com/2008/11/wsus-30-approving-multiple-updates-for.html">WSUS 3.0 and Powershell</a> another thing which bugged me about the WSUS 3.0 GUI is the Cleanup Wizard. This is a really useful tool for keeping your WSUS deployment running efficiently.</p>
<p>It includes the ability to clean out computers which haven&#8217;t synched with the WSUS server for over 30 days &#8211; unfortunately 30 days is the default value which can&#8217;t be changed in the GUI. Arrgh! I&#8217;ve wanted to run this tool for a long time, but 30 days is way too short and I wanted to be able to specify my own time frame, e.g. 200 days.</p>
<p>Luckily I met <a href="http://blogs.technet.com/wsus/default.aspx">Marc Shepard</a> at Teched EMEA and during a Q&amp;A session for WSUS I asked why it wasn&#8217;t possible to change the 30 day value. This developed into a discussion along the lines that the WSUS team didn&#8217;t wish to promote removing lots of computers from WSUS &#8211; I can&#8217;t remember exactly why now, I think it was along the lines of preventing lots of computers which were actually still alive synching back into WSUS. (Apologies if this is not the correct reason)</p>
<p>Anyway, even though we had a slight difference of opinion about this (I want to remove old computers so that the monthly patch compliance reports are more accurate), Marc kindly agreed to send me over a Powershell script which would run the cleanup computer part of the wizard under the caveat that this was not their recommended method for maintenance.</p>
<p>So here it is, this version will give you a list of computers who have not synched over the specified number of days:</p>
<p><span style="color:#000000;">[</span><span style="color:#008080;">reflection.assembly</span><span style="color:#000000;">]::</span><span style="color:#8b4513;">LoadWithPartialName</span><span style="color:#000000;">(</span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">Microsoft.UpdateServices.Administration</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;">) | </span><span style="color:#5f9ea0;font-weight:bold;">out-null</span></p>
<p><span style="color:#800080;">$days</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#5f9ea0;font-weight:bold;">read-host</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">Please enter the number of days since Last Sync you wish to query for</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;"><br />
</span><span style="color:#800080;">$ts</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#5f9ea0;font-weight:bold;">new-object</span><span style="color:#000000;"> </span><span style="color:#800000;">TimeSpan</span><span style="color:#000000;">(</span><span style="color:#800080;">$days</span><span style="color:#000000;">,</span><span style="color:#000000;">0</span><span style="color:#000000;">,</span><span style="color:#000000;">0</span><span style="color:#000000;">,</span><span style="color:#000000;">0</span><span style="color:#000000;">)</span></p>
<p><span style="color:#800080;">$updateServer</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;font-style:italic;">WSUSServername</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;"><br />
</span><span style="color:#800080;">$wsus</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(</span><span style="color:#800080;">$updateServer</span><span style="color:#000000;">,</span><span style="color:#0000ff;">$false</span><span style="color:#000000;">)</span></p>
<p><span style="color:#800080;">$computerScope</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#5f9ea0;font-weight:bold;">new-object</span><span style="color:#000000;"> </span><span style="color:#800000;">Microsoft.UpdateServices.Administration.ComputerTargetScope</span><span style="color:#000000;"><br />
</span><span style="color:#800080;">$computerScope</span><span style="color:#000000;">.ToLastSyncTime </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> [</span><span style="color:#008080;">DateTime</span><span style="color:#000000;">]::</span><span style="color:#8b4513;">UtcNow</span><span style="color:#000000;">.</span><span style="color:#8b4513;">Subtract</span><span style="color:#000000;">(</span><span style="color:#800080;">$ts</span><span style="color:#000000;">)<br />
</span><span style="color:#800080;">$wsus</span><span style="color:#000000;">.GetComputerTargets(</span><span style="color:#800080;">$computerScope</span><span style="color:#000000;">) | </span><span style="color:#5f9ea0;font-weight:bold;">sort</span><span style="color:#000000;"> </span><span style="color:#800000;">fulldomainname</span><span style="color:#000000;"> | </span><span style="color:#5f9ea0;font-weight:bold;">ft</span><span style="color:#000000;"> </span><span style="color:#800000;">fulldomainname</span><span style="color:#000000;">,</span><span style="color:#800000;">lastsynctime</span></p>
<p>If you wish to remove them then simply change the last line to:</p>
<p><span style="color:#800080;">$wsus</span><span style="color:#000000;">.GetComputerTargets(</span><span style="color:#800080;">$computerScope</span><span style="color:#000000;">) | </span><span style="color:#5f9ea0;font-weight:bold;">foreach-object</span><span style="color:#000000;"> {</span><span style="color:#000080;">$_</span><span style="color:#000000;">.Delete();}</span></p>
<p>I have added both of these scripts and the ApproveMultipleUpdates scripts from the last post to the <a href="http://powergui.org/entry.jspa?categoryID=21&amp;externalID=2061">WSUS PowerGUI Powerpack</a>.</p>
<p>Also keep an eye on the <a href="http://www.microsoft.com/technet/scriptcenter/scripts/sus/server/default.mspx?mfr=true">WSUS section of the MS Script Center</a> Marc is hoping to soon publish some more Powershell scripts for managing WSUS.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2008/11/wsus-30-cleaning-out-redundant-computers.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WSUS 3.0: Approving Multiple Updates for a Specific Computer with Powershell</title>
		<link>http://www.jonathanmedd.net/2008/11/wsus-30-approving-multiple-updates-for-a-specific-computer-with-powershell.html</link>
		<comments>http://www.jonathanmedd.net/2008/11/wsus-30-approving-multiple-updates-for-a-specific-computer-with-powershell.html#comments</comments>
		<pubDate>Tue, 11 Nov 2008 11:43:00 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[tech.ed]]></category>
		<category><![CDATA[wsus]]></category>

		<guid isPermaLink="false">http://jonathanmedd.wordpress.com/2008/11/11/wsus-30-approving-multiple-updates-for-a-specific-computer-with-powershell/</guid>
		<description><![CDATA[One of the best uses I have found for Powershell is for plugging gaps in holes left by GUI admin tools which don&#8217;t do everything that you want. Prior to Powershell you would typically have had to wait for the next service pack / full release / possibly ever before you had the functionality that [...]]]></description>
			<content:encoded><![CDATA[<p>One of the best uses I have found for Powershell is for plugging gaps in holes left by GUI admin tools which don&#8217;t do everything that you want. Prior to Powershell you would typically have had to wait for the next service pack / full release / possibly ever before you had the functionality that you wanted.</p>
<p>I had an example of this recently with the GUI tool for WSUS 3.0. Essentially I was kicking off a project where we were going to target a particular group of machines for patching and the first step was to run a report for specific machines and then approve the updates to what WSUS calls a ComputerTargetGroup.</p>
<p>The problem with this is that although WSUS can provide you with a report which shows which updates are required for a specific machine, there is no way in the GUI that you can approve all of those updates in one go. Since it takes 5 clicks per approval, you only have to get into the 10&#8217;s of updates before this goes beyond tedious.</p>
<p>I knew there were some sample scripts for <a href="http://www.microsoft.com/technet/scriptcenter/scripts/sus/default.mspx?mfr=true">WSUS and Powershell</a> on the Script Center so I headed over there and checked out some of the scripts. (This initial investigation led to the creation of the <a href="http://powergui.org/entry.jspa?externalID=2061&amp;categoryID=21">PowerGUI Powerpack for WSUS</a> &#8211; fairly basic, but it was great way to learn what sort of things would be available)</p>
<p>So I then spent some time working on a script to approve multiple updates for a specific computer which is shown below. I&#8217;d love to say that I put this all togther myself, but really it is another illustration of how helpful people within the Powershell community are. <a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/">Shay Levi</a> was incredibly helpful putting the initial work of this script together, we got most of the way there, but it got left at the point where I could retrieve as objects the list of updates required for the computer, but couldn&#8217;t figure out how to approve them for a particular computer group.</p>
<p>Fortunately at Teched I went to a couple of sessions on WSUS 3.0 run by Program Manager Marc Shepard who contributes to the <a href="http://blogs.technet.com/wsus/default.aspx">WSUS team blog</a>. I went to see Marc at the &#8216;Ask The Experts&#8217; stand inbetween the two sessions he was running. He seemed genuinely pleased to find someone with a particular request for the product (I guess it&#8217;s free so hey that must be a tricky product to be a Program Manager for <img src='http://www.jonathanmedd.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />   ), took on my unfinished Powershell script and started coding away.</p>
<p>By the time I got to the next session Marc had a working script for me &#8211; there is no better recommendation for going to Teched than this!</p>
<p>The script is below. Before running the ApproveMultipleUpdates script you need to establish three things:</p>
<ul>
<li>WSUS Server Name</li>
<li>Full DNS name of the computer you wish to query</li>
<li>The Computer Group Target ID for the group you wish to make the approval to. You can find this either by using the PowerGUI Powerback or the code below:</li>
</ul>
<p><span style="color:#990000;">Get-ComputerTargetGroups.ps1</span></p>
<p><span style="color:#000000;">[</span><span style="color:#008080;">void</span><span style="color:#000000;">][</span><span style="color:#008080;">reflection.assembly</span><span style="color:#000000;">]::</span><span style="color:#8b4513;">LoadWithPartialName</span><span style="color:#000000;">(</span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">Microsoft.UpdateServices.Administration</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;">)<br />
</span><span style="color:#800080;">$updateServer</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">WSUSServername</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;"><br />
</span><span style="color:#800080;">$wsus</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(</span><span style="color:#800080;">$updateServer</span><span style="color:#000000;">,</span><span style="color:#0000ff;">$false</span><span style="color:#000000;">)</span></p>
<p><span style="color:#800080;">$wsus</span><span style="color:#000000;">.GetComputerTargetGroups()</span></p>
<p><span style="color:#990000;">ApproveMultipleUpdates.ps1</span></p>
<p><span style="color:#000000;">[</span><span style="color:#008080;">void</span><span style="color:#000000;">][</span><span style="color:#008080;">reflection.assembly</span><span style="color:#000000;">]::</span><span style="color:#8b4513;">LoadWithPartialName</span><span style="color:#000000;">(</span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">Microsoft.UpdateServices.Administration</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;">)</span></p>
<p><span style="color:#800080;">$updateServer</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">WSUSServername</span><span style="color:#800000;">&#8220;</span><span style="color:#000000;"><br />
</span><span style="color:#800080;">$machineName</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#5f9ea0;font-weight:bold;">Read-Host</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">Please enter the full DNS name of the computer you wish to approve updates for</span><span style="color:#800000;">&#8220;</span></p>
<p><span style="color:#800080;">$wsus</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(</span><span style="color:#800080;">$updateServer</span><span style="color:#000000;">,</span><span style="color:#0000ff;">$false</span><span style="color:#000000;">)</span></p>
<p><span style="color:#800080;">$updateScope</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#5f9ea0;font-weight:bold;">new-object</span><span style="color:#000000;"> </span><span style="color:#800000;">Microsoft.UpdateServices.Administration.UpdateScope</span></p>
<p><span style="color:#800080;">$updateScope</span><span style="color:#000000;">.includedInstallationStates </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">NotInstalled</span><span style="color:#800000;">&#8220;</span></p>
<p><span style="color:#800080;">$com</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#800080;">$wsus</span><span style="color:#000000;">.GetComputerTargetByName(</span><span style="color:#800080;">$machineName</span><span style="color:#000000;">)<br />
</span><span style="color:#008000;"><br />
</span><span style="color:#800080;">$groupid</span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="font-weight: bold;">Read-Host</span><span style="color:#000000;"> </span><span style="color:#800000;">&#8220;</span><span style="color:#800000;">Please enter the Computer Group Target ID</span><span style="color:#800000;">&#8220;</span></p>
<p><span style="color:#800080;">$group</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#800080;">$wsus</span><span style="color:#000000;">.GetComputerTargetGroup(</span><span style="color:#800080;">$groupid</span><span style="color:#000000;">)<br />
</span><span style="color:#800080;">$action</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> [Microsoft.UpdateServices.Administration.UpdateApprovalAction]::Install</span></p>
<p><span style="color:#800080;">$updates</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#800080;">$com</span><span style="color:#000000;">.GetUpdateInstallationInfoPerUpdate(</span><span style="color:#800080;">$updateScope</span><span style="color:#000000;">)<br />
</span><span style="color:#800080;">$updates</span><span style="color:#000000;"> | </span><span style="color:#5f9ea0;font-weight:bold;">foreach-object</span><span style="color:#000000;"> {</span><span style="color:#800080;">$uid</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#000080;">$_</span><span style="color:#000000;">.UpdateId; </span><span style="color:#800080;">$u</span><span style="color:#000000;"> </span><span style="color:#ff0000;">=</span><span style="color:#000000;"> </span><span style="color:#800080;">$wsus</span><span style="color:#000000;">.GetUpdate(</span><span style="color:#800080;">$uid</span><span style="color:#000000;">); </span><span style="color:#800080;">$u</span><span style="color:#000000;">.Title; </span><span style="color:#800080;">$u</span><span style="color:#000000;">.Approve(</span><span style="color:#800080;">$action</span><span style="color:#000000;">,</span><span style="color:#800080;">$group</span><span style="color:#000000;">);}</span></p>
<p>This is going to save us hours of work &#8211; big thanks to the guys who helped me out!</p>
<p>(I think a version of this script should be making its way onto the MS Script Center at some point too)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2008/11/wsus-30-approving-multiple-updates-for-a-specific-computer-with-powershell.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
