PowerShell

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

Windows Server 2012 R2 – IIS6 install state

Posted on Updated on

In troubleshooting some ConfigMgr 2012 R2 web service point configuration problems in my home environment, I was having real problems trying to locate the install status of IIS6 Metabase and Compatibility components within the Server Manager GUI.  Ultimately I turned to PowerShell to get the answer I needed.


Import-Module servermanager

Get-WindowsFeature -Name *metabase*

Get-WindowsFeature -Name *compat*

iis6_inst_status

(in fact, I’m still trying to find this information in the GUI for server manager! thank you PowerShell!!)

PowerShell Delete App-V Cache

Posted on Updated on

I wrote this little PowerShell script to cleanup the App-V cache for both the shared directory and a user’s data.  Run this script in an elevated PowerShell command (or ISE) window.  Optionally, you can distribute this with ConfigMgr using the below command line. Note that this will need to run with user’s rights in order to access their %appdata% folder.

%windir%\sysnative\windowspowershell\v1.0\powershell.exe -executionPolicy bypass -file .\DeleteAppVCache.ps1

DeleteAppVCache.ps1

Script updated/fixed 6/5/2014

 

Import-Module "C:\Program Files\Microsoft Application Virtualization\Client\AppvClient\AppvClient.psd1"

net stop AppVClient
Get-AppvClientPackage -All | Remove-AppVClientPackage
net stop AppVClient

Set-Location -Path env:
Remove-Item C:\ProgramData\App-V\* -recurse

$UserAppData = Get-Content -Path appdata
Remove-Item $UserAppData\Microsoft\AppV\Client\Catalog\Packages\* -recurse
Remove-Item $UserAppData\Microsoft\AppV\Client\VFS\* -recurse

$UserAppData = Get-Content -Path localappdata
Remove-Item $UserAppData\Microsoft\AppV\Client\Integration\* -recurse
Remove-Item $UserAppData\Microsoft\AppV\Client\VFS\* -recurse

net start AppVClient
Get-AppvPublishingServer | Sync-AppvPublishingServer