Powershell fun – Parsing for Protocols Redux


That problem I'd previously mentioned? Turns out I had a bad package registered for some old VS project. Remove-AppxPackage <packagefullname> and voila! No more error.

My original command

powershell -c "ForEach ($p in $(Get-AppxPackage)) { ForEach ($n in (Get-AppxPackageManifest $p).package.applications.application.extensions.extension.protocol.name) { $n + ' -- ' + $p.packagefullname } }"

One suggested alternative in the "probably not the most elegant but workable" category was rather interesting

powershell -c "Get-AppxPackage | Get-AppxPackageManifest | ForEach { $m = $_; $m.package.applications.application.extensions.extension.protocol.name | ForEach {if ($_) {@{$_ = $m.package.identity.name}}} }"

Same net result, but with 2 differences:

  1. Output is a nice table of columns (not just a simple dump of "protocol -- pkgfullname")
  2. Not as resilient to errors -- emitted an error about file not found and quit (the former had the virtue of giving output for everything it could parse, though uglier output and not really sortable)

But handy enough for a quick'n'dirty hack.

Comments (0)

Skip to main content