Category Archives: tech.ed

WSUS 3.0: Approving Multiple Updates for a Specific Computer with Powershell

One of the best uses I have found for Powershell is for plugging gaps in holes left by GUI admin tools which don’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.

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.

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’s of updates before this goes beyond tedious.

I knew there were some sample scripts for WSUS and Powershell 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 PowerGUI Powerpack for WSUS – fairly basic, but it was great way to learn what sort of things would be available)

So I then spent some time working on a script to approve multiple updates for a specific computer which is shown below. I’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. Shay Levi 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’t figure out how to approve them for a particular computer group.

Fortunately at Teched I went to a couple of sessions on WSUS 3.0 run by Program Manager Marc Shepard who contributes to the WSUS team blog. I went to see Marc at the ‘Ask The Experts’ 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’s free so hey that must be a tricky product to be a Program Manager for 😉 ), took on my unfinished Powershell script and started coding away.

By the time I got to the next session Marc had a working script for me – there is no better recommendation for going to Teched than this!

The script is below. Before running the ApproveMultipleUpdates script you need to establish three things:

  • WSUS Server Name
  • Full DNS name of the computer you wish to query
  • 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:

Get-ComputerTargetGroups.ps1

[void][reflection.assembly]::LoadWithPartialName(Microsoft.UpdateServices.Administration)
$updateServer = WSUSServername
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($updateServer,$false)

$wsus.GetComputerTargetGroups()

ApproveMultipleUpdates.ps1

[void][reflection.assembly]::LoadWithPartialName(Microsoft.UpdateServices.Administration)

$updateServer = WSUSServername
$machineName = Read-Host Please enter the full DNS name of the computer you wish to approve updates for

$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($updateServer,$false)

$updateScope = new-object Microsoft.UpdateServices.Administration.UpdateScope

$updateScope.includedInstallationStates = NotInstalled

$com = $wsus.GetComputerTargetByName($machineName)

$groupid= Read-Host Please enter the Computer Group Target ID

$group = $wsus.GetComputerTargetGroup($groupid)
$action = [Microsoft.UpdateServices.Administration.UpdateApprovalAction]::Install

$updates = $com.GetUpdateInstallationInfoPerUpdate($updateScope)
$updates | foreach-object {$uid = $_.UpdateId; $u = $wsus.GetUpdate($uid); $u.Title; $u.Approve($action,$group);}

This is going to save us hours of work – big thanks to the guys who helped me out!

(I think a version of this script should be making its way onto the MS Script Center at some point too)

Video of Teched Powershell Panel Discussion

Just got notification through of the various video available for Powershell Panel Discussion for the Teched Online website:

Download (High res – approx 900MB): http://microsofttech.fr.edgesuite.net/TechEdOnline/Videos/406_high.wmv

Or if you prefer not to crack your monitor / TV screen

Download (Low res): http://microsofttech.fr.edgesuite.net/TechEdOnline/Videos/406_low.wmv

Streaming (Low res): http://mfile.akamai.com/14853/wmv/microsofttec.download.akamai.com/14853/TechEdOnline/Videos/406_low.asx

What you get from the video that you might not have picked up on the audio is that we spent most of the time laughing which just goes to show how much fun everyone had doing it!

TechEd Powershell Panel Discussion

After the TechEd Powershell Panel Discussion we all realised that none of us had arranged for a photo to be taken. 🙁

We’re still waiting for the video, so thought we could screengrab something of that, but Tobias found that someone else had put a photo they had taken of it on their blog.

From left to right below:

Me, Ben Pearce, Richard Siddaway, Dmitry Sotnikov, James O’Neill, Tobias Weltner, Jeffrey Snover and MoW.

Tech.ed Day 5

All good things must come to an end I guess, so after an amazing week at Teched it was time to attend the last few sessions.

I attended a couple of sessions I have a particular interest in – WSUS 3.0, with Marc Shepard Program Manager. The sessions had promised some Powershell so I had taken along with me a script which I hadn’t quite finished off and asked Marc about it afterwards at the Ask the Experts stand.

He seemed genuinely interested and very kindly worked through most of it, then took it away with him and said he would either get it back to me next week or might have time before the next session. So I duely turned up for the next session and was really pleased when Marc presented me and demonstrated the finished script! I will blog about it in detail next week after I have been able to test it back in work, but for me this was a real value for going to Teched, you wouldn’t get that kind of help from someone so close to the product at a normal training course.

Marc ran a really great second session, which was a Q&A on WSUS 3.0. He gave some really great answers and took a lot of feedback about the product which you believed he actually would try to do something about.

For the final session of the week I went to a repeat of the Powershell session with Ben and Jeffrey. Due to the fact a lot of people had left the conference by this time, the attendence wasn’t massive, but both presenters were so relaxed that it made for a really funny session with lots of jokes. (Possibly more on this in a later post)

Once finished it was off on the provided coaches to the airport and the usual waiting around. Luckily I went with Richard Siddaway, a colleague of his and the aforementioned Ben Pearce so the time went pretty quick.

All in all I had a brilliant time, got loads out of it and now need to work on a plan for how to get there next year!

Tech.ed Day 4

Posting the day after this time, will keep it brief. All you need to know is:

  • Powershell sessions all day with Jeffrey Snover and the exuberant Ben Pearce.
  • Powershell community dinner, 18 attendees. Jeffrey + MoW = mental evening
  • Got back so late it was time for the live stream of the Powerscripting podcast so thought I might as well stay up late and watch it for the first time – great fun.

The amount of sleep I am getting is decreasing by about half an hour each night – it started at about 5 hours on Sunday. This is so much fun though I don’t even seem to notice…..

Tech.ed Day 3

So a bit more of a relaxed day today after yesterday’s panel discussion craziness.

Some great Powershell sessions today.

James O’Neill – how to get effective output from Powershell, in particular OpenXML – I really got challenged to give this a try for creating reports, it looks very useful and not too difficult.

http://blogs.technet.com/jamesone/archive/2008/11/05/slides-and-scripts-from-open-xml-powershell-reporting-session-in-barcelona.aspx

Plus I saw Jeffrey Snover present for the first time – it was awesome, all about stuff coming up in V2 of Powershell – there will be CTP3 of V2 in Dec 08.

Also Dmitry kindly gave me some of his time for an interview for the podcast, so we will get that out in November hopefully.

All finished off by the UK country drinks party, a very chilled evening.

Tech.ed Day 2

So its late, this will be brief, but I had another brilliant day at Tech.ed. The highlight of course was the Powershell Panel Discussion.

I decided to get it out to the get-scripting podcast asap since it was so good, so there is a new episode with just that for content.

Apart from that I went to a couple of interesting Exchange 2007 sessions, an Operations Manager 2007 R2 session and had a nice dinner with some new friends.

This is so much fun……..

Tech.ed Day 1

The day flew by really. Wandered round Ramblas in the morning, checking out some of Barcelona.

Then the guy I met yesterday (Andy) offered to show me the ropes in getting the Metro to the conference centre which was really helpful.

Quick and easy registration, followed by some lunch and then the first session I went to, Steve Riley. This was amazing, a great presenter and he really made security interesting. (not easy). I think I may have to check out some of his other sessions.

Later on I went to a session on Sysvol in 2008, i.e. you can replace NTFRS, with DFSR. One thing I learnt was you need to get to sessions early because this was totally full and I was the second last person allowed in.

An evening reception and chance to check out vendors and Ask the Experts. I met Mow and Tobias on the Powershell stand which was great. I also thanked the very nice ladies at the Technet Plus stand for the competition I won to get me the place here – they want me to do a video for them on Wednesday so naturally was happy to return the favour.

Just before leaving I was invited out by those great guys at Specops, so an excellent meal was had by all.

Plenty of sessions to get stuck into tomorrow and of course the Powershell panel discussion.

Powershell Panel Discussion at Teched

Tuesday Nov 4th 2 – 3 I will be hosting a Powershell Panel discussion on a stage adjacent to the Tech Talk Fishbowl.

Invited attendees include:

  • Dmitry Sotnikov – Powershell MVP
  • Richard Siddaway – Powershell MVP
  • MoW – Powershell MVP
  • James O’Neill – Microsoft
  • Some guy called Jeffrey

I will be recording the session for the get-scripting podcast, apparently it will also be videoed and available at the Teched Online website.