2012-09-17

Delete old/unwanted updates from WSUS

I wanted to delete all updates related to the "Drivers" classification in WSUS, as we no longer uses this solution for such updates.

I discovered that the "Server Cleanup Wizard" would not help me.

First of all, I removed all approvals/declines for all Drivers in the WSUS MMC (or GUI if you like). By running the cleanup wizard, all downloaded files where removed. The updates were still in the WSUS database (SUSDB).

I did some searches, and found PoshWSUS, and the "Remove-WSUSUpdate" commandlet. This uses the WSUS API and removes updates from the database based on the search feature in the API. Some experimenting by providing some known driver vendor names, confirmed that this worked.

I still wanted to remove all updates from the driver classification, and preferably automatic.

There seems to be few methods in the WSUS API to filter on classifications (other than the create-new-auto-approve method), so I had to use my limping Powershell powers and write something myself.
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer('localhost',$False)
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | Out-Null
$wsus.getupdates() | Where {$_.UpdateClassificationTitle -eq 'Drivers'} | ForEach-Object { $wsus.DeleteUpdate($_.Id. UpdateID); Write-Host $_.Title removed }

As I write this, these lines are happily removing my odd 18 thousand drivers updates (slooooow).
Screenshot



If you ever stumble upon this blog, searching for something like this,I have to warn you that I will not guarantee any success using this, and that you might end up with a broken WSUS install.

2012-09-14

Ubuntu upstart and init.d - the pain

I've started using start/stop/restart from the new and improved upstart package on Ubuntu (as I got tired of the warnings when using the old /etc/init.d/ way).

I like it, but it is a major pain in the back to remember what service is converted to upstart and not, and this were starting to give me quite an irritation. During a coffee break, I uttered that these upstart commands should check if there were an init.d script if the service were missing from /etc/init, and that got me thinking. It would be trivial to write an patch, but I guess the reason this feature is missing, already is discussed in the upstart community, and probably never would be accepted.

My solution is to use functions in bash and wrap around these commands.

I made a master function _start()



function _start() {
  if [ -f /etc/init/$1.conf ]; then
    /sbin/$2 $1
  elif [ -x /etc/init.d/$1 ]; then
    /etc/init.d/$1 $2
  else
    echo "$2: Unkown job: $1"
    return 1
  fi;
}

This master is used by the three small wrapper functions start(), stop() and restart():



function start() {
  _start $1 start;
}

function stop() {
  _start $1 stop;
}

function restart() {
  _start $1 restart;
}

I've put all four functions into /etc/profile.d/upstart.sh and now I don't have to remember which service is using what. To reduce the need of cut and paste, you can download upstart.sh directly.