Created
July 23, 2024 00:37
-
-
Save quonic/68c7ef56a9d854b840a926a5a0fd79b8 to your computer and use it in GitHub Desktop.
Get Microsoft Store Apps with ID when Get-AppxPackageManifest does not return results when running under the System context
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
$InstalledAppxPackages = Get-AppxPackage -AllUsers | |
$AumidList = foreach ($app in $InstalledAppxPackages) { | |
# Get the AppId from the manifest file | |
try { | |
$ManifistPath = Join-Path -Path $app.InstallLocation -ChildPath "AppxManifest.xml" | |
$ManifestPathLeaf = Split-Path -Path $app.InstallLocation -Leaf | |
if ($(Test-Path -Path $ManifistPath -ErrorAction SilentlyContinue)) { | |
[xml]$Manifest = Get-Content -Path $ManifistPath -ErrorAction Stop | |
$Name = $Manifest.Package.Identity.Name | |
$Publisher = @( | |
"$ManifestPathLeaf" -split '_' | Select-Object -First 1 | |
"$ManifestPathLeaf" -split '_' | Select-Object -Last 1 | |
) -join '_' | |
$Id = $Manifest.Package.Applications.Application.Id | |
if ($Publisher -and $Id -and $Publisher -like "*$Name*") { | |
$Id | ForEach-Object { | |
Write-Output "$($Publisher)!$($_)" | |
} | |
} | |
} | |
} | |
catch {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment