Retry Installation for Approved application using PowerShell

I wrote a post on What’s new in application requests in Configuration Manager 1906 over at 4sysops.com https://4sysops.com/archives/whats-new-in-application-requests-in-sccm-1906/ One of the things that is new i the possibility to Retry an Installation if it fails or is uninstalled manually for example.

In the post over at 4Sysops I had three sample scripts on how to Create, Approve and Deny application requests using PowerShell so it could be automated. I got a question the other day if you can do a Retry Install as well using PowerShell and of course we can. Here is a PowerShell script to achieve that.

Sample command line: Powershell.exe -executionpolicy bypass -file RetryAppinstall.Ps1 “W101test120” “7-zip 18.06”

The script:

[CmdletBinding()]
Param(
    [string]$MachineName,
    [string]$AppName
  )

Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1"
$SiteCode = (Get-WmiObject -Namespace root\sms -Query 'SELECT SiteCode FROM SMS_ProviderLocation').SiteCode
Set-Location "$($SiteCode):"
$NameSpace ="ROOT\SMS\site_$($SiteCode)"

$AppID = (Get-CMApplication -Name "$AppName").ModelName
$SMSID = (Get-CMDevice -Name "$MachineName").SMSID

$reqObj = Get-WmiObject -Namespace $NameSpace -Class SMS_UserApplicationRequest | Where {$_.ModelName -eq $AppID -and $_.RequestedMachine -eq $MachineName}
$reqObjPath = $reqObj.__PATH

Invoke-WmiMethod -Path $reqObjPath -Name RetryInstall

More articles

Allurity acquires Onevinn

Stockholm, Sweden – April 11, 2025

Security Testing: You’re Playing By The Rules, They’re Rewriting The Game

Sauron had a ring to rule them all, but unfortunately, no tool was forged in the fires of Mount...

Will your WiFi, smart cards and VPN stop working on Feb 11?

Did you read about Microsoft planning to change the default behaviour on all certificate based...