PowerShell Script Lists App-V Package Dependencies (Dynamic Suite Composition, DSC)

  • Scripting
  • Published Jan 6, 2010 Updated Oct 27, 2010

Update 2010-04-20: Thanks to Stefan Henseler the script now works correctly with multiple dependencies in a single file. Be sure to download the current version below.

App-V’s Dynamic Suite Composition is a powerful feature in that it allows multiple “bubbles” to share the same virtual environment. In other words, package A can be made dependent on package B. But if DSC is used extensively, dependencies between packages tend to become difficult to manage - there seems to be no simple way of listing all packages’ dependencies. Well, I have written a PowerShell script that does just that.

Using Get-AppVPackageDependencies

Just call the script with the path (UNC or local) to a folder containing packages. The script will recursively search the path given for OSD files and analyze each OSD file for dependencies. Here is some sample output:

PS D:\> .\Get-AppVPackageDependencies.ps1 .\

============================================================
Dependencies found:
============================================================

DaveSoft_CopyRite_Vista.CopyRite -> Nvu
Opera -> Firefox_JRE

============================================================
All packages found:
============================================================

Name                             GUID
----                             ----
Nvu                              3AAC7EE6-84C4-4021-966B-56C52FF95AAF
WinDirStat                       3C5E1C59-D56E-4463-B9A0-5190034E6223
DaveSoft_CopyRite_Vista.CopyRite 4A7697E4-ED02-4D87-A8F0-88D7DEB914DE
Firefox_JRE                      999E8458-D477-4975-B3C8-3BCE1252B991
Opera                            24D14B13-1838-45B2-9DAC-78D0A7432F69

In the example above, the script was located in the same folder as the packages, thus the parameter “.".

Get-AppVPackageDependencies - the Script

Here is the source code. Let me know if it is useful to you.

#
#	Get-AppVPackageDependencies by Helge Klein, sepago GmbH, http://blogs.sepago.de/helge/
#
#	Usage:
#
#	Get-AppVPackageDependencies <path to folder containing packages>
#
#	Script version: 1.1
#
#	-	Minor changes to allow for multiple dependencies in a OSD file (thanks to Stefan Henseler)
#

#Requires -Version 2

param(
	[ValidateNotNullOrEmpty()]
	[System.String[]] $PackageBasePath
)

# Initialize a hash table that stores GUID -> name associations
$Packages = @{}

# Get a list of all .OSD files below the base path passed in
$SFTFiles	= Get-ChildItem $PackageBasePath -filter *.osd -force -recurse

# Store each OSD file's data (name and GUID)
foreach ($SFTFile in $SFTFiles)
{
	# Read the OSD file
	[xml]	$SFTFileXML	= Get-Content $SFTFile.FullName

	# Store relevant information
	$PkgName	= $SFTFileXML.SOFTPKG.NAME
	$PkgGUID	= $SFTFileXML.SOFTPKG.IMPLEMENTATION.CODEBASE.GUID

	if ($Packages.ContainsKey($PkgGUID) -eq $false)
	{
		$Packages.Add($PkgGUID, $PkgName)
	}
}

Write-Output "`n============================================================`nDependencies found:`n============================================================`n"

# Process each package's dependencies
foreach ($SFTFile in $SFTFiles)
{
	# Read the OSD file
	[xml]	$SFTFileXML	= Get-Content $SFTFile.FullName

	$PkgDependencies	= $SFTFileXML.SOFTPKG.IMPLEMENTATION.VIRTUALENV.DEPENDENCIES.CODEBASE

	foreach ($PkgDependency in $PkgDependencies)
	{
		# Extract package information (again)
		$PkgName	= $SFTFileXML.SOFTPKG.NAME
		$PkgGUID	= $SFTFileXML.SOFTPKG.IMPLEMENTATION.CODEBASE.GUID

		# Extract the GUID the package depends on
		$PkgDependencyGUID	= $PkgDependency.GUID

		# Look up the depending package's name
		if ($PkgDependencyGUID -ne $null -and $Packages.ContainsKey($PkgDependencyGUID))
		{
			Write-Output "$PkgName -> $($Packages.Get_Item($PkgDependencyGUID))"
		}
	}
}

Write-Output "`n============================================================`nAll packages found:`n============================================================"
Write-Output $Packages | format-table -auto @{Label="Name";Expression={$_.Value}},@{Label="GUID";Expression={$_.Name}}

Download

You can download a digitally signed version of the script here.

Comments

Related Posts

PowerShell Script: Test Chrome, Firefox & IE Browser Performance

PowerShell Script: Test Chrome, Firefox & IE Browser Performance
There is more than one way to test the performance of web browsers like Chrome, Firefox, or IE, but regardless of how you do it, you need a consistent workload that makes the browsers comparable. Unless you are testing with synthetic benchmarks (which come with a plethora of problems of their own) you need a way to automate browsers opening tabs and loading URLs. This article presents a simple solution to do just that.
Scripting

Latest Posts

Fast & Silent 5 Watt PC: Minimizing Idle Power Usage

Fast & Silent 5 Watt PC: Minimizing Idle Power Usage
This micro-series explains how to turn the Lenovo ThinkCentre M90t Gen 6 into a smart workstation that consumes only 5 Watts when idle but reaches top Cinebench scores while staying almost imperceptibly silent. In the first post, I showed how to silence the machine by replacing and adding to Lenovo’s CPU cooler. In this second post, I’m listing the exact configuration that achieves the lofty goal of combining minimal idle power consumption with top Cinebench scores.
Hardware

Fast & Silent 5 Watt PC: Lenovo ThinkCentre M90t Modding

Fast & Silent 5 Watt PC: Lenovo ThinkCentre M90t Modding
This micro-series explains how to turn the Lenovo ThinkCentre M90t Gen 6 into a smart workstation that consumes only 5 Watts when idle but reaches top Cinebench scores while staying almost imperceptibly silent. In this first post, I’m showing how to silence the machine by replacing and adding to Lenovo’s CPU cooler. In a second post, I’m listing the exact configuration that achieves the lofty goal of combining minimal idle power consumption with top Cinebench scores.
Hardware