Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new function for overwriting detectionRules on existing app. #184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

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.

1 participant