Skip to content

Conversation

@henrili
Copy link

@henrili henrili commented Nov 26, 2024

By copying parts of code from Add-IntuneWin32App and Set-IntuneWin32App and merging into the Set-IntuneWin32AppDetectionRule, it is now possible to overwrite the ruleset on existing apps.

This is useful for automating update of existing apps. Example usage in custom script after downloading latest installer and generating intunewin file.

Connect-MSIntuneGraph -TenantID $tenantName -ClientID $scriptClientID -ClientSecret $scriptClientSecret

$appObject = Get-IntuneWin32App -ID $intuneAppId
if($null -eq $appObject){
    Write-Error "No app with given ID found. $intuneAppId"
    exit 1
}
Update-IntuneWin32AppPackageFile -ID $intuneAppId -FilePath $intuneWinFile
Set-IntuneWin32App -ID $intuneAppId -AppVersion $newVersion

$newRule = new-IntuneWin32AppDetectionRuleMSI -ProductCode $productCode -ProductVersionOperator greaterThanOrEqual "$newVersion"
Set-IntuneWin32AppDetectionRule -ID $intuneAppId -DetectionRule $newRule

@CWWallin
Copy link

Been looking for this as well. I added DetectionRule in Set-IntuneWin32App, but I think your way is a better way to go. Would love to see this merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants