Wednesday, 12 March 2014

SCCM 2012 R2 - Scripted removal of expired or superseded updates with Powershell

Hi All,

Unfortunately SCCM 2012 still has a requirement to manually remove expired and superseded updates. Quite sometime ago I found and modified Trevor Sullivan's Powershell script for use with SCCM 2007. As I have just build a new SCCM 2012 R2 environment for a client I decided I would spend the time to update the script for use with SCCM 2012.

Note: By removing superseded updates via this script I would assume that the newer superseding updates are being included in new deployments.

Original script source:
Trevor Sullivan's Blog
http://trevorsullivan.net/2011/11/29/configmgr-cleanup-software-updates-objects/

New and Updated Features:
  • Updated the script to a parameterized advanced Powershell script.
  • Added Powershell Help functionality.
  • Updated to enable targeting of remote primary site servers.
  • Updated to only trigger a DP refresh for packages which have had updates removed.
  • Commented out the 'SMS_UpdatesAssignment' (Deployments) code section as updates listed in this WMI class now appear to automatically mirror the updates contained in the associated 'Software Update Group' so do not need to reviewed\updated.
  • Added progress bars.
  • Added  the use of Powershell transcripts for basic logging.
  • Tested against SCCM 2012 R2
Actions Performed:
  • Removal of Expired or Superseded updates from:
    • Software Update Groups
    • Software updates packages
  • Distribution Point refresh is triggered for packages which have been modified.
Usage:  

.\Remove-SCCMExpiredSupersededContent_1.0.ps1 [PrimarySiteServerName]

Note: If no server name is specified you will be prompted to provide one.


Download