Systems Management

App Revision Cleanup: How to Leverage PowerShell with ConfigMgr

Topics: Systems Management

Have you ever gone to delete or edit a global condition only to find that it’s in use by an application? You remove that requirement in the application, thinking you can then edit the global condition, but you still can’t. What now? You need to delete the application revision that was using that requirement. What a pain! So many clicks. There are also other times when having revisions can cause you problems, and you just want those revisions to go away. This is where leveraging PowerShell with ConfigMgr can make app revision cleanup easy. Let’s talk about how we can make that happen.

Revision History

Application Revision History

Here you see I have Revisions 17-19. Revision 18 is the one that really annoys me, but I don’t need anything older than the current one, so I’m going to clean the other ones up too. I’m going to use PowerShell to resolve this problem because it is easy. I typically like to launch the PowerShell ISE right from the console. Doing so sets up the environment for me.

App Revision Cleanup with PowerShell ISE

App Revision Cleanup - Connect via Windows PowerShell ISE

Once PowerShell ISE launches, I click “Play” on the script. That opens and loads the ConfigMgr PowerShell module and connects to the ConfigMgr drive. Your site code is named like so: PS PS2:>

App Revision Cleanup - Windows PowerShell ISE

$AppName = “FakeApp – Testing Stuff”
$CMApp = Get-CMApplication -Fast -Name $AppName
$CMAppRevisions = Get-CMApplicationRevisionHistory -InputObject $CMApp | Where-Object {$_.IsLatest -ne “True”}
Foreach ($CMAppRevision in $CMAppRevisions) {
Write-Output “Removing Revision $($CMAppRevision.CIVersion)”
Remove-CMApplicationRevisionHistory -InputObject $CMAppRevision -Force
}

Results

Application Revision History - Results

This method saves you a lot of clicks and time especially if there are a lot of revisions. You can also use wild cards in the app names, if you like, or just have it grab all ConfigMgr apps and dump the revision history all at one time. Another example of how this method is useful can be found on GitHub where it provides additional information while the script is running.

PowerShell with ConfigMgr is amazing! Would you like to know how to review ConfigMgr app deployment type requirements using PowerShell? Make sure to check out my recent post. Do you have any questions about app revision cleanup? Please connect with me at @gwblok.

Back to Top