Detect applications by ProductCode instead of substring matching - #6
Merged
Merged
Conversation
Test-TecharyApp matched only on DisplayName -like "*$Name*", which fails in both directions. False negative: it could not detect anything by winget package ID, which is the identifier Install-TecharyApp takes. No ARP DisplayName contains the string "7zip.7zip", so Test-TecharyApp -Name 7zip.7zip returned False on a machine with 7-Zip installed. False positive: "Teams" matches "Microsoft Teams Meeting Add-in for Microsoft Office", so it reports Teams as installed on a machine with no Teams desktop app. Detection now works most-precise-first. winget records the ARP subkey name in ProductCode, an MSI product GUID or a plain name such as "7-Zip", so with the manifest index available this becomes a direct key lookup and is definitive. Failing that it tries an exact DisplayName, then the previous substring behaviour, then MSIX. The substring tier is kept deliberately. Removing it would flip detections from True to False across the estate and trigger reinstalls. It is now reported through MatchedBy so an imprecise match is visible rather than indistinguishable from an exact one. Makes no network calls. Get-ManifestIndex and Get-CustomApp take -NoRefresh, and detection uses it, because this runs on a schedule on every endpoint. Names are escaped before wildcard comparison. A name containing [ or ] was previously treated as a wildcard pattern and silently matched nothing. MSIX enumeration uses -AllUsers when elevated, for the same reason as the uninstall path: SYSTEM sees almost none of its own packages. Adds -Detailed, returning what matched and the installed version. The default return stays a boolean, so existing callers are unaffected. Verified against the BETA implementation on the same machine: 7zip.7zip goes False to True via ProductCode, and 7-Zip, Teams and WindowsCalculator are unchanged. No case flips to False.
TecharyJames
changed the base branch from
feat/prebuilt-manifest-index
to
BETA
September 19, 2026 11:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
Test-TecharyAppmatched only onDisplayName -like "*$Name*", which fails in both directions.False negative. It could not detect anything by winget package ID — the identifier
Install-TecharyApptakes. No ARPDisplayNamecontains the string7zip.7zip, so on a machine with 7-Zip installed:False positive.
TeamsmatchesMicrosoft Teams Meeting Add-in for Microsoft Office, reporting Teams as installed on a machine with no Teams desktop app.Detection order
winget records the ARP subkey name in
ProductCode— an MSI product GUID, or a plain name such as7-ZiporNotepad++. With the index from #3 available, that makes detection a direct key lookup.ProductCode→ ARP subkeyDisplayName(from-Nameor the custom catalogue)DisplayNameThe substring tier is kept deliberately. Removing it would flip detections from
TruetoFalseacross the estate and trigger reinstalls. It is now reported throughMatchedBy, so an imprecise match is visible rather than indistinguishable from an exact one.Other changes
Get-ManifestIndexandGet-CustomApptake-NoRefresh, and detection uses it, because this runs on a schedule on every endpoint.[or]was previously treated as a wildcard pattern and silently matched nothing.-AllUserswhen elevated, for the same reason as Make MSIX removal work under SYSTEM and stop deprovisioned apps returning #4: SYSTEM sees almost none of its own packages.-Detailed, returning what matched and the installed version. The default return stays a boolean, so existing callers are unaffected.Verification
Against the BETA implementation, same machine:
7-Zip is in fact installed (
7-Zip 26.03 (x64)), so the single change is a false negative corrected. No case flips toFalse.-Detailedoutput:Boolean contract confirmed:
7zip.7zip→True (Boolean),NoSuchAppZZZ→False (Boolean).Tier 1 requires the package to be in the index from #3. Without it, detection falls back to tiers 2–4, which is the current behaviour plus the escaping fix.