npb consultants

IT Consultancy Services

  • Home
  • Downloads
  • Blog
  • Contact
  • Portal

Archive for February, 2009

Querying WSUS with Powershell

Wednesday, February 11th, 2009

Out of the box, WSUS is capable of reporting update status in a number of permutations, but I always seem to need some combination that I can’t easily derive using the GUI.

I recently needed to determine the status of a particular update (KB958644) for a number of computers that spanned different WSUS groups. I knew that there was a .NET API for WSUS management and so Powershell seemed to the most appropriate tool to use. I found this script example which got me started.

After a bit of head scratching I came up with the script below. It reads a list of computer names from a plain text file (Computers.txt) and calls the GetUpdateStatus function for each computer listed, passing the computer name and update string to the function.

The GetUpdateStatus function pulls the computer object from WSUS and then attempts to locate the update specified by the string. The status of the update is then returned.

[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
 
if (!$wsus) {$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();}
 
function GetUpdateStatus([string]$a, [string]$b)
{
  $ComputerScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope;
  $ComputerScope.NameIncludes = $a;
 
  $UpdateScope = new-object Microsoft.UpdateServices.Administration.UpdateScope;
  $UpdateScope.ExcludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::NotApplicable;
  $UpdateScope.TextIncludes  = $b;
 
  $Computers = $wsus.GetComputerTargets($ComputerScope);
 
  $Computers | foreach-object{
    $_.FullDomainName + " (Status @ " + $_.LastReportedStatusTime + ")" | write-host;
 
    $Updates = $_.GetUpdateInstallationInfoPerUpdate($UpdateScope);
    $Updates | foreach-object{
      $Update = $wsus.GetUpdate($_.UpdateId);
      "   "+$Update.Title+"   {"+$_.UpdateInstallationState +"}" | write-host;
    }
  }
}
 
cls
Get-Content Computers.txt | Foreach-Object {GetUpdateStatus $_ "KB958644"}

Posted in Powershell, Scripting | No Comments »

Open Audit

Monday, February 9th, 2009

Open Audit is an Open Source application distributed under the Creative Commons license to provide a hardware and software inventory of systems on your network. It uses Windows VBScript and Linux BASH scripts on the client to post audit info to a PHP/MySql server application.

The application comes with a number of built-in queries and reports for examining the audit data and is easily extensible if you don’t mind rolling your own code.

What I like is the fact that it doesn’t need a client agent installing on your systems, in fact Windows systems can be audited remotely.

I have to declare an interest as I am a contributor to the project, but if you’re looking for a budget auditing solution you might want to consider it.

The project website can be found here http://www.open-audit.org/ and hosts well supported forums if you run into problems. If you do choose to try it out, I highly recommend obtaining the latest code from the Subversion repository.

Posted in Open Audit | No Comments »

  • Search

  • You are currently browsing the There’s Geeks in the Bushes … blog archives for February, 2009.

  • Pages

    • Nick Brown
  • Archives

    • November 2009
    • April 2009
    • February 2009
    • January 2009
  • Categories

    • Open Audit (1)
    • Scripting (2)
      • Powershell (2)
    • Windows (2)
      • Deployment (1)
      • Vista (1)
 

©2007 All Rights Reserved.  •  Design by Free CSS Templates  •  Icons by FAMFAMFAM.