Monthly Archives: November 2014

SCCM 2012: Get expired Advertisements

There are some clean up tasks a System Center Configuration Manager 2012 Administrator can perform on a regular basis. One should be to check which advertisements are expired.

Yes, I talk about advertisements in SCCM 2012. I know SCCM 2012 talks about deployments, but if you deploy a Package in SCCM (not an Application) then SCCM internally stores this deployment in the WMI class SMS_Advertisement. See also.

There is no PowerShell Cmdlet for SCCM 2012 SP1 which could give me this information directly, so I have created a script, that can be used in two ways:

  1. document which deployments are expired (only does not document the current assigned schedule) in a CSV format.
  2. delete the expired deployments.

So you can call the script with different parameters.

Command line: Getexpiredadvertisements.ps1 -log [String] -sitecode [String] -siteserver [String] -document [Bool] -delete [Bool]

Example: Getexpiredadvertisements.ps1 -log “c:\it\expiredads.csv” -sitecode “ABC:” -siteserver “SCCM01” -document $True -delete $False

Possible Parameters:

  • Log: Defines name and path of the written CSV file
  • Sitecode: SCCM Site Code, Example ABC:
  • Siteserver: SCCM Site Server Name
  • Document:  Defines, if expired Advertisements get documented to the CSV file, possible values: $True/$False
  • Delete: Defines, if expired Advertisements get deleted in SCCM, possible values: $True/$False


  • Run this script in PowerShell x86
  • The script is tested with PowerShell 2.0 and SCCM 2012 SP1
  • SCCM administrator permissions
  • The Configuration Manager PowerShell Modul must be installed on the machine, where you run the script

The script can be downloaded here.