Querying .APPV Package Properties Part 2

powershell_appv_logoFollowing on from Part 1, we can also query the properties of an App-V 5.0 .APPV package with another cmdlet included in the Virtual Engine App-V 5.0 .APPV PowerShell CmdLets; Get-AppV5FilePackage.  The main difference with this cmdlet (when compared to Get-AppV5FileXml and Get-AppV5FileXmlPackage) is that it returns a custom PSObject with a simpler property namespace and additional package information.

To populate our object we can run this:

[code]C:\PS> $AppVPackage = Get-AppV5FilePackage –AppV C:\Mozilla_Firefox_v17.0.appv[/code]

Going back to our example in Part 1, we can then query this object for both the VersionId and PVAD like so:

[code]C:\PS> $AppVPackage | Select-Object VersionId,FileSystemRoot | Format-List

VersionId      : fd215f39-f317-447d-aa79-7fe6c35e73f6
FileSystemRoot : C:\Program Files\Mozilla Firefox[/code]

Our custom PSObject also includes details of all the files in package and the uncompressed size. If you want to know how much space a package will take when loaded into the App-V 5 client cache, then this is the command for you!

To return the uncompressed package size we could run:

[code]$AppVPackage.UncompressedSize
43738570[/code]

If you want this in MB, easy:

[code]C:\PS> ($AppVPackage.UncompressedSize/1MB).ToString(“N2”)
41.71[/code]

Want the total number of files in the package?

[code]C:\PS> $AppVPackage.Files.Count
85[/code]

Need a list of all the files in the .APPV package?

[code]C:\PS> $AppVPackage.Files | Select-Object FullName

FullName
——–
Registry.dat
Root/components/binary.manifest
Root/components/browsercomps.dll
Root/defaults/pref/channel-prefs.js
Root/defaults/pref/local-settings.js
Root/dictionaries/en-US.aff
Root/dictionaries/en-US.dic
Root/extensions/%7B972ce4c6-7e08-4474-a285-3208198ce6fd%7D/icon.png
Root/extensions/%7B972ce4c6-7e08-4474-a285-3208198ce6fd%7D/install.rdf
Root/modules/services-aitc/.mkdir.done
Root/modules/services-common/.mkdir.done
Root/modules/services-crypto/.mkdir.done
Root/modules/services-notifications/.mkdir.done
Root/modules/services-sync/.mkdir.done
Root/modules/services-sync/engines/.mkdir.done
Root/modules/sessionstore/.mkdir.done
Root/searchplugins/amazondotcom.xml
Root/searchplugins/bing.xml
Root/searchplugins/eBay.xml
Root/searchplugins/google.xml
Root/searchplugins/twitter.xml
Root/searchplugins/wikipedia.xml
Root/searchplugins/yahoo.xml
Root/webapprt/omni.ja
Root/webapprt/webapprt.ini
Root/override.ini
Root/mozilla.cfg
Root/install.log
Root/AccessibleMarshal.dll
Root/application.ini
Root/blocklist.xml
Root/breakpadinjector.dll
Root/chrome.manifest
Root/crashreporter-override.ini
Root/crashreporter.exe
Root/crashreporter.ini
Root/D3DCompiler_43.dll
Root/d3dx9_43.dll
Root/dependentlibs.list
Root/firefox.exe
Root/freebl3.chk
Root/freebl3.dll
Root/gkmedias.dll
Root/libEGL.dll
Root/libGLESv2.dll
Root/maintenanceservice.exe
Root/maintenanceservice_installer.exe
Root/mozalloc.dll
Root/mozglue.dll
Root/mozjs.dll
Root/mozsqlite3.dll
Root/msvcp100.dll
Root/msvcr100.dll
Root/nspr4.dll
Root/nss3.dll
Root/nssckbi.dll
Root/nssdbm3.chk
Root/nssdbm3.dll
Root/nssutil3.dll
Root/omni.ja
Root/platform.ini
Root/plc4.dll
Root/plds4.dll
Root/plugin-container.exe
Root/precomplete
Root/removed-files
Root/smime3.dll
Root/softokn3.chk
Root/softokn3.dll
Root/ssl3.dll
Root/update-settings.ini
Root/updater.exe
Root/updater.ini
Root/webapp-uninstaller.exe
Root/webapprt-stub.exe
Root/xpcom.dll
Root/xul.dll
Root/firefox.exe.0.ico
Root/firefox.exe.1.ico
FilesystemMetadata.xml
StreamMap.xml
PackageHistory.xml
AppxManifest.xml
AppxBlockMap.xml
[Content_Types].xml[/code]

Hopefully, these cmdlets will be useful? As an example, we’ve used the Get-AppV5FilePackage cmdlet to create HTML .APPV package reports. Happy PoShing Open-mouthed smile

Querying .APPV Package Properties Part 1

powershell_appv_logoSo 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):

image

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!

Using PowerShell

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-AppV5FileXmlGet-AppV5FileXmlPackage and/or Get-AppV5FilePackage. This post covers the first two and Part 2 of this post covers the Get-AppV5FilePackage command.

Get-AppV5FileXml

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!):

[code]C:\PS> (Get-AppV5FileXml –AppV C:\Mozilla_Firefox_v17.0.appv –XML AppxManifest).Package.Identity.VersionId

fd215f39-f317-447d-aa79-7fe6c35e73f6

C:\PS>[/code]

If we want the PVAD directory, this is stored in the FileSystemMetadata.xml file. Easy (again, all on a single line!):

[code](Get-AppV5FileXml –AppV C:\Mozilla_Firefox_v17.0.appv –XML FilesystemMetadata).Metadata.FileSystem.Root

C:\Program Files\Mozilla Firefox

C:\PS>[/code]

This method loads each file into it’s own XmlDocument. Is there a way to load all the XML properties at once? You betcha!

Get-AppV5FileXmlPackage

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:

[code]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>[/code]

In Part 2, we can use yet another method: Get-AppV5FilePackage. Happy PowerShelling Open-mouthed smile

Documenting App-V 5.0 Packages

Continuing our series of posts on the Virtual Engine App-V 5.0 .APPV PowerShell CmdLets, this one will show you how to quickly document your .APPV packages’ contents. The Save-AppV5FileReport cmdlet generates a HTML report of information contained within the .APPV package contents. Here’s an example summary report (detailed reports are also available):

Generating Single Reports

Generating summary reports (such as the one above) simply requires running the following command:

[code]C:\PS> Save-AppV5FileReport –AppV C:\Mozilla_Firefox_v17.0\Mozilla_Firefox_v17.0.appv[/code]

This will generate a Mozilla_Firefox_V17.0_Report.html file in the source C:\Mozilla_Firefox_v17.0\ directory. If we wanted a detailed report instead we could run:

[code]C:\PS> Save-AppV5FileReport –AppV C:\Mozilla_Firefox_v17.0\Mozilla_Firefox_v17.0.appv –Detailed[/code]

Documenting Multiple Packages

Creating a report for a single package is fine, but what if we wanted to document all packages on a share or in a folder? Fortunately this is simple. If you wanted each package report in the source package directory, we can do so like this:

[code]C:\PS> Get-ChildItem C:\Packages\ -Include *.appv -Recurse | % { Save-AppV5FileReport -AppV $_.FullName }

Directory: C:\Packages\GoogleChrome_v23.0.1271.91

Mode                LastWriteTime     Length Name
—-                ————-     —— —-
-a—        02/05/2013     12:36       8884 GoogleChrome_v23.0.1271.91_Report.html

Directory: C:\Packages\Mozilla_Firefox_v17.0

Mode                LastWriteTime     Length Name
—-                ————-     —— —-
-a—        02/05/2013     12:36       8802 Mozilla_Firefox_v17.0_Report.html

Directory: C:\Packages\Paint.Net_v3.5.10

Mode                LastWriteTime     Length Name
—-                ————-     —— —-
-a—        02/05/2013     12:36       8770 Paint.NET_v3.5.10_Report.html[/code]

What about if we wanted all the reports in a single location? Again, pretty straight forward. The Save-AppV5FileReport cmdlet has a –FilePath parameter that we can specify the output location. Note: this folder is not automatically created so make sure it exists! Our command to achieve this is:

[code]C:\PS> Get-ChildItem C:\Packages\ -Include *.appv -Recurse | % { Save-AppV5FileReport -AppV $_.FullName -FilePath C:\Packages\Reports\ }

Directory: C:\Packages\Reports

Mode                LastWriteTime     Length Name
—-                ————-     —— —-
-a—        02/05/2013     12:40       8884 GoogleChrome_v23.0.1271.91_Report.html
-a—        02/05/2013     12:40       8802 Mozilla_Firefox_v17.0_Report.html
-a—        02/05/2013     12:40       8770 Paint.NET_v3.5.10_Report.html[/code]

Hopefully you’ll find these HTML reports useful. We are planning to add sequencer reports into this module in the near future too, so stay tuned! Happy PoShing 😀