So you have an App-V 5.0 package (in this example I’ll use Mozilla Firefox) and you’d like to know various properties about the package without loading it into the App-V 5 client. The sequencer creates numerous files by default that expose some extremely pertinent information, i.e. the PackageId. The PackageId is specified in both the template <PackageName>_DeploymentConfig.xml and <PackageName>_UserConfig.xml files.
Unfortunately for us, other useful details such as the VersionId and Primary Virtual Asset Directory (PVAD) are stored within the <PackageName>.appv file. This is a compressed archive and can simply be opened with Windows Explorer by renaming the file with a .ZIP extension. Within this file are some more files (generated by the Sequencer):
If we want to find out information such as the VersionId or Primary Virtual Asset Directory (PVAD directory) without loading the package into the App-V 5.0 client, we have to manually rename the file, open the archive and inspect the various files (AppxManifest.xml for the VersionId and FileSystemMetadata.xml for the PVAD). Whilst this is fine, it is manual and if we forget to rename the file back to a .APPV file we leave the package unusable!
This is what the Virtual Engine App-V 5.0 Package PowerShell CmdLets are for! Included are three CmdLets that can help us here: Get-AppV5FileXml, Get-AppV5FileXmlPackage and/or Get-AppV5FilePackage. This post covers the first two and Part 2 of this post covers the Get-AppV5FilePackage command.
This cmdlet will extract the contents of a single XML file within an .APPV package. The results are returned as a System.Xml.XmlDocument that we can then interrogate. No more manually renaming the archive, extracting and then loading the file.
Going back to our example, if we wanted the VersionId of an .APPV package we need to interrogate the AppxManifest.xml file. To accomplish this we can run this command (all on a single line!):
C:\PS> (Get-AppV5FileXml –AppV C:\Mozilla_Firefox_v17.0.appv –XML AppxManifest).Package.Identity.VersionId fd215f39-f317-447d-aa79-7fe6c35e73f6 C:\PS>
If we want the PVAD directory, this is stored in the FileSystemMetadata.xml file. Easy (again, all on a single line!):
(Get-AppV5FileXml –AppV C:\Mozilla_Firefox_v17.0.appv –XML FilesystemMetadata).Metadata.FileSystem.Root C:\Program Files\Mozilla Firefox C:\PS>
This method loads each file into it’s own XmlDocument. Is there a way to load all the XML properties at once? You betcha!
This command bundles all the default sequencer generated XML files into a single XmlDocument object. This includes the contents of the AppxManifest.xml, StreamMap.xml, AppxBloackMap.xml, PackageHistory.xml and FileSystemMetadata.xml files. Each XML file is loaded under the <AppV5> element within the XML document and therefore, the paths are extended slightly.
Taking our example, if want to get the VersionId and PVAD we can do this instead:
C:\PS> $Mozilla = Get-AppV5FileXmlPackage –AppV C:\Mozilla_Firefox_v17.0.appv C:\PS> $Mozilla.AppV5.Package.Identity.VersionId fd215f39-f317-447d-aa79-7fe6c35e73f6 C:\PS> $Mozilla.AppV5.Metadata.FileSystem.Root C:\Program Files\Mozilla Firefox C:\PS>