Skip to content

Instantly share code, notes, and snippets.

@quonic
Created July 23, 2024 00:37
Show Gist options
  • Save quonic/68c7ef56a9d854b840a926a5a0fd79b8 to your computer and use it in GitHub Desktop.
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
$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