PowerShell Script to test App-V 5.0 Packages

Posted on Updated on

I use the below PowerShell script code for testing my App-V packages prior to publishing them officially.  The top portion will add the package on the local system.  While the second portion will remove the package once my testing is complete.  For easiest execution, I use the PowerShell ISE to just run the code segments that I need.  The values to add for yourself are:

  1. pkgPath – the UNC to the AppV files
  2. pkgAppV – the name of the .app file
  3. pkgXML – the name of the .xml file
  4. pkgName – change the “Part_Of_App_Name” value to what is appropriate (such *java*)

Script updates:

  • 2/11/2014 – to handle multiple cached apps with the same name part
  • 6/16/2014 – to better generalize use of the “AppName”
# Script from https://t3chn1ck.wordpress.com

# First code adds the package
clear
$pkgPath = "\\appv5_server\share" + "\"
$pkgName = "AppName"
$pkgAppV = $pkgPath + $pkgName + ".appv"
$pkgXML = $pkgPath + $pkgName + "_DeploymentConfig.xml"
Add-AppvClientPackage -Path $pkgAppV -DynamicDeploymentConfiguration $pkgXML | Publish-AppvClientPackage</pre>

# Next code removes the package but only when 
# there's one app with the name part
$pkg = Get-AppvClientPackage -Name $pkgName
Unpublish-AppvClientPackage -Name $pkg.Name
Remove-AppvClientPackage -Name $pkg.Name

# Removes multiple packages of the same name part
foreach ($pkg in Get-AppvClientPackage -Name $pkgName) {
	write-host $pkg.Name
	Unpublish-AppvClientPackage -Name $pkg.Name
	Remove-AppvClientPackage -Name $pkg.Name
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s