Your company's ad could live here and reach over 50,000 people a month!

Share This Post

PowerShell / System Center

SCCM 2012 – Removing old revision

Hi All,

every time you change something to any application or deployment type, SCCM keeps a history of this change and will delete it, after specific period of time. This behaviour can be changed on the site maintenance, task Delete Unused application revisions. the default is 60 days.

Anyway, i wanted to know how many revisions i had for each application as well as the application version. To do it, i used powershell

the posh script below will shows you the Application Name, Version and number of revisions.

$cmApps = Get-CMApplication
foreach ($cmApp in $cmApps)
{
	$cmAppRevision = $cmApp | Get-CMApplicationRevisionHistory
	"{0} - {1} - {2}" -f $cmApp.LocalizedDisplayName, $cmApp.SDMPackageVersion, $cmAppRevision.Count
}

 

Easy, but what if i don’t want to wait for SCCM to delete it for me, what can I do? well..there is another powershell for it.

the below powershell will delete all revisions that is not the last one, leaving you with only 1 review, the last one.

$cmApps = Get-CMApplication
foreach ($cmApp in $cmApps)
{
	$cmAppRevision = $cmApp | Get-CMApplicationRevisionHistory
	for ($i = 0;$i -lt $cmAppRevision.Count-1;$i++) { Remove-CMApplicationRevisionHistory -name $cmApp.LocalizedDisplayName -revision $cmAppRevision[$i].CIVersion -force }
}

 

This script is really useful when you have many people changing applications and what i found in the past is that if you have many revisions, OS Deployment and Application deployment may start failing without any apparent reason.

Share This Post

Leave a Reply