PowerShell Script to list Software Updates in a Software Update Group

 

Hi everybody,

In a recent Workshop that I was teaching I got asked how to list all of the security updates in a software update group. So I wrote a quick PowerShell script to do exactly that.

Here is the code I used while on R2 CU1

############################################################################################

$modulelocation = 'F:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\configurationmanager.psd1'
$SUG = 'Security Updates'

Import-Module $modulelocation
CD PRI:

$SoftwareUpdates = (get-cmsoftwareupdategroup | Where {$_.LocalizedDisplayN -eq $SUG}).Updates
Foreach ($SoftwareUpdate in $SoftwareUpdates){
(Get-CMSoftwareUpdate -Id $SoftwareUpdate).LocalizedDisplayName

}

############################################################################################

image
UPDATE

After going to R2 CU2 The cmdlets changed slightly.

Found a simpler command below

############################################################################################

$modulelocation = 'F:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\configurationmanager.psd1'
$SUG = 'Security Updates'

Import-Module $modulelocation
CD PRI:

(Get-CMSoftwareUpdate -UpdateGroupName $SUG).LocalizedDisplayName

############################################################################################

image

You will just need to change the two initial variables

$Modulelocation to where your psd1 sits. See Matts blog for details on this.

$SUG to the name of your Software Update Group.

This will simply list all of the updates so you can paste it into any Change Request you need to create for Software Updates.

Hopefully you find this useful but more than that hopefully this gets you started with some PowerShell. A fantastic free course that I always recommend to my students if you not sure where to begin is this MVA course run by Jeffrey Snover and Jason Helmick.

Getting Started with PowerShell 3.0 Jump Start

Feel free to comment with your own useful PowerShell script or even a new improved version of mine below…