0% found this document useful (0 votes)
68 views24 pages

APPV Performance Troubleshooting Guide

Uploaded by

loopzilla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views24 pages

APPV Performance Troubleshooting Guide

Uploaded by

loopzilla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

APPV TROUBLESHOOTING &

PERFORMANCE GUIDE

APPV TroubleShooting & Performance Guide

Matt Balzan Microsoft Senior PFE


1. SYSINTERNALS SUITE.......................................................................................................................................................2
2. xPERF (Windows Performance Toolkit)...........................................................................................................................3
3. APPV Profile for Clients (WPR)........................................................................................................................................6
4. APPV PowerShell Debug scripts...................................................................................................................................... 7
5. Deployment, User & Manifest script examples.............................................................................................................22
6. Measuring Disk Performance........................................................................................................................................24

NOTE TO READER:

ALL THE SCRIPTS IN THIS DOCUMENT CONTAIN OUR STANDARD DISCLAIMER HOWEVER PLEASE MAKE SURE YOU
ALWAYS TRY OUT THESE SCRIPTS IN YOUR TEST ENVIRONMENT BEFORE YOU ARE CONFIDENT TO USE THEM IN
PRODUCTION.

1. SYSINTERNALS SUITE

Download the above suite from here:

https://docs.microsoft.com/en-gb/sysinternals/downloads/sysinternals-suite

and extract the contents on your APPV Client test VM to C:\Tools\SysInternalsSuite

TIP: Run this in an elevated PowerShell prompt to add your new path to the current path.
Please note the semi colon before the path must be present. Highlighted in RED below example.

[Environment]::SetEnvironmentVariable("Path",$Env:Path + ";C:\SysInternalsSuite", "Machine")

This will enable all the suite apps to run directly from the CMD prompt.

USING PROCESS MONITOR (PROCMON)

1. Launch CMD prompt (as Admin)


2. TYPE: procmon -?

The following useful switches will appear:


So normally to setup your ProcMon for the first time you will run and add the switch: procmon /accepteula

This will write a reg key (HKCU\Software\Sysinternals\Process Monitor - EulaAccepted {DWORD: 1}) to the client user
hive so that the end user license agreement will not appear again.

SETTING THE FILTER ALTITUDE FOR PROCMON

1. Import reg key (ProcMon_Filter_Altitude.reg)


2. Reboot machine
3. Put deny up for everyone so ProcMon cannot revert it to default (see reg key comments)
4. Launch ProcMon

Now you will be able to run ProcMon lower than other services (like McAfee or other security vendors)

2. xPERF (Windows Performance Toolkit)

Download the adksetup.exe from here:

https://developer.microsoft.com/en-us/windows/downloads/windows-8-1-sdk

and run it.

Choose first radio button to install to default location.

click Next
Click No and Next

Click Accept
Select Windows Performance Toolkit and click Install

Click Close

Go to Start > Windows Kits > Windows Performance Recorder to launch.


3. APPV Profile for Clients (WPR)

Download the APPV Windows Performance Recorder profile from here:

http://www.tmurgent.com/Tools/xPerf_AppVProfile/AppVProfileforClients.zip

Extract the AppVProfileforClients.wprp file to C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit

Running a trace

1. Open Windows Performance Recorder from Start menu


2. Click Add Profiles…
3. Choose the above AppVProfileforClients.wprp file and click Open.
4. Under Resource Analysis, choose*:
a. CPU usage
b. File I/O activity
c. Registry I/O activity
d. Network I/O activity
5. Click the START button and do your app test launch
6. Click STOP to save the WPR file
7. Click either Open in WPA or Open Folder to view your trace as shown below.
* the more you choose, the bigger the WPR file will be

For more info click here to watch the Channel 9 MSDN videos:

https://channel9.msdn.com/Events/Build/BUILD2011/HW-926P (Intro to new WPA interface)

https://channel9.msdn.com/Events/Build/BUILD2011/HW-925P (Customizing WPA Trace Views)

https://channel9.msdn.com/Events/Build/BUILD2011/HW-922P (Capturing and Analyzing Performance Traces)


4. APPV PowerShell Debug scripts

Open an elevated PowerShell ISE console and copy/paste the following contents into the top script area (if all the scripts
are missing: save the list of mentioned scripts using the extension as .ps1 [example: test.ps1] to C:\Tools\APPV Scripts.
The names of the files are up to you and have no impact on the script)

How to Automate the Creation of App-V 5.0 Debug Command Prompts

# Directory to create App-V Debug shortcuts


$Directory = "$Env:UserProfile\Desktop\AppVDebugCMDs"

# Creating Directory Folder


New-Item -ItemType directory -Path $Directory

# Getting all client packages registered in the Client Catalog


$Packages = Get-AppVClientPackage -all

# Looping through each Package and creating a cmd shortcut


foreach($entry in $Packages){ $PName = $entry.Name
$PI = [string]$entry.PackageID
$VI = [string]$entry.VersionID
$Ver = [string]$entry.Version
$PD = $PI + "_" + $VI
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$Directory\$PName $Ver DebugCMD.lnk")
$Shortcut.TargetPath = "c:\windows\system32\cmd.exe"
$Shortcut.WorkingDirectory = "C:\windows\System32"
$Shortcut.Arguments = "/appvve:$PD"
$Shortcut.Save()
}
#End of script

This will be an output example:


How to Automate the creation of App-V 5.0 Connection Group Debug Commands

# Directory to create App-V Debug shortcuts


$Directory = "$Env:UserProfile\Desktop\AppV_Debug_Cmds_CG"

# Creating Directory Folder


New-Item -ItemType directory -Path $Directory

$Packages = Get-AppVClientConnectionGroup -all

foreach($entry in $Packages){

$PacName = $entry.Name
$Ver = $entry.version
$PName = $PacName
$PI = [string]$entry.GroupID
$VI = [string]$entry.VersionID
$PD = $PI + "_" + $VI

$WshShell = New-Object -comObject WScript.Shell


$Shortcut = $WshShell.CreateShortcut("$Directory\$PName DebugCMD.lnk")
$Shortcut.TargetPath = "c:\windows\system32\cmd.exe"
$Shortcut.WorkingDirectory = "C:\windows\System32"
$Shortcut.Arguments = "/appvve:$PD"
$Shortcut.Save()
}
How to troubleshoot the Client using the Event Logs

Very efficient way of viewing all the APPV Logs (Admin, Operational & Virtual Applications) in one viewing without
waiting for the Event Viewer (below) to open and start consuming data to show.

The following script will open a browser (or you can use Out-GridView) and display all logs in chronological order, thus
making troubleshooting on your client easier.

<#
.DISCLAIMER The sample scripts are not supported under any Microsoft standard support program or service. The
sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties
including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire
risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall
Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any
damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of
business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or
documentation, even if Microsoft has been advised of the possibility of such damages. #>

# Adding threading culture change so that get-winevent picks up the messages, if PS culture is set to none en-US then
the script will fail

[System.Threading.Thread]::CurrentThread.CurrentCulture = New-Object "System.Globalization.CultureInfo" "en-US"

$FilterXML_Admin = @"
<QueryList>
<Query Id="0" Path="Microsoft-AppV-Client/Admin">
<Select Path="Microsoft-AppV-Client/Admin">*[System[TimeCreated[timediff(@SystemTime) &lt;=
86400000]]]</Select>
</Query>
</QueryList>
"@

$GWE_All = Get-WinEvent -FilterXml $FilterXML_Admin -ErrorAction SilentlyContinue


$FilterXML_Operational = @"
<QueryList>
<Query Id="0" Path="Microsoft-AppV-Client/Operational">
<Select Path="Microsoft-AppV-Client/Operational">*[System[TimeCreated[timediff(@SystemTime) &lt;=
86400000]]]</Select>
<Suppress Path="Microsoft-AppV-Client/Operational">*[System[(EventID=101 or EventID=102 or EventID=14023 or
EventID=14024 or EventID=14025 or EventID=14026)]]</Suppress> </Query>
</QueryList>
"@

$GWE_All += Get-WinEvent -FilterXml $FilterXML_Operational -ErrorAction SilentlyContinue

$FilterXML_VirtApps = @"
<QueryList>
<Query Id="0" Path="Microsoft-AppV-Client/Virtual Applications">
<Select Path="Microsoft-AppV-Client/Virtual Applications">*[System[TimeCreated[timediff(@SystemTime) &lt;=
86400000]]]</Select>
</Query>
</QueryList>
"@

$GWE_All += Get-WinEvent -FilterXml $FilterXML_VirtApps -ErrorAction SilentlyContinue

$GWE_All = $GWE_All | sort TimeCreated -Descending

#################
# Out-GridView (uncomment below line to view in PowerShell table mode)
#################

#$GWE_All | select TimeCreated,Id,LogName,TaskDisplayName,LevelDisplayName,Message | Out-GridView

#################
# Convertto-Html
#################

# HTML output path and name


$HTML_Output = "c:\temp\allEL.html"

# Style Sheet for HTML Report


$CSS = "<style>"
$CSS = $CSS + "BODY{background-color:white;font-family:Arial;}"
$CSS = $CSS + "TABLE{border-width: 1px;border-style: solid;border-color: #00668a;border-collapse: collapse;
fontfamily:Arial; font-size:12px;}"
$CSS = $CSS + "TH{height: 20px;border-width: 1px;padding: 0px;border-style: solid;border-color:
#00668a;backgroundcolor:#00668A; color:white; font-size:12px;}"
$CSS = $CSS + "TD{border-width: 1px;padding: 4px;border-style: solid;border-color: #00668a;backgroundcolor:PaleBlue;
vertical-align:top;}"
$CSS = $CSS + "</style>"

$GWE_All | select TimeCreated,Id,LogName,TaskDisplayName,LevelDisplayName,Message | ConvertTo-Html -head


$CSS -body "<H3>All App-V 5 Event Logs</H3>" | Out-File "$HTML_Output"

Invoke-Item $HTML_Output
How to troubleshoot APPV packages using the Logman command and sending it to a log file

<#
.DISCLAIMER The sample scripts are not supported under any Microsoft standard support program or service. The
sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties
including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire
risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall
Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any
damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of
business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or
documentation, even if Microsoft has been advised of the possibility of such damages. #>

$trace = "APPV5Debug"
$Date = get-date -f "ddMMhhmm"
$userpath = "$env:USERPROFILE\Desktop\APPVDebug"
$ETL_trace_output = "$userpath\appv5Debug.etl"
$EVTX_trace_output = "$userpath\appv5Debug$Date.evtx"
$TXT_trace_output = "$userpath\appv5Debug$Date.txt"

$Random = Get-Random
$ProviderFile = "$userpath\AppVClientProviders$Random.txt"

$Providers = Get-WinEvent -ListProvider Microsoft-AppV*

$AppVProviders = $Providers.Name | sort

foreach($entry in $AppVProviders){

if($entry -ne "Microsoft-AppV-SharedPerformance")


{ ac $ProviderFile $entry
}

write-host

$query_logman = logman query APPV5DEBUG

if($LASTEXITCODE -eq "-2144337918"){ write-host


"Data Collector Set was not found" write-host
write-host "Creating Logman Trace..."
logman.exe create trace $trace -o "$ETL_trace_output" -f bincirc -max 512 -pf "$ProviderFile" -ct perf -ow --v write-host
}

elseif($LASTEXITCODE -eq "0"){


write-host "Data Collector Set already exists..."
write-host "Deleting to ensure all the App-V Collectors are available..." write-host
logman.exe delete $trace write-host
"Creating Logman Trace..."
logman.exe create trace $trace -o "$ETL_trace_output" -f bincirc -max 512 -pf "$ProviderFile" -ct perf -ow --v write-host
}

$Start_Trace = read-host -prompt "Do you want start the trace now? (Y/N)"
if ($Start_Trace -eq "Y" -or $Start_Trace -eq "y")
{ write-host "Starting Logman Trace $Trace" -f
yellow logman.exe start $trace write-host
}
elseif ($Start_Trace -eq "N" -or $Start_Trace -eq "n"){
write-host "You will need to start the trace manually from perfmon.exe..." -f yellow
}

$Stop_Trace = read-host -prompt "Do you want stop the trace now? (Y/N)"

if ($Stop_Trace -eq "Y" -or $Stop -eq "y"){ write-host


"Stopping Logman Trace $Trace" -f yellow
logman.exe stop $trace write-host
write-host "Converting Trace to EVTX format..."
tracerpt.exe -l $ETL_trace_output -lr -of EVTX -o $EVTX_trace_output write-host
write-host "Converting Trace to TXT format..."
Netsh trace convert $ETL_trace_output $TXT_Trace_output DUMP=TXT report=no
write-host "TXT file written to $TXT_Trace_output..." write-host
write-host "Opening EVTX trace - $EVTX_Trace_output..."
Invoke-Item $EVTX_Trace_output
}
elseif ($Stop_Trace -eq "N" -or $Stop_Trace -eq "n"){
write-host "You will need to stop the trace manually from perfmon.exe..." -f yellow
}

#End of script

How to time Publishing apps

<#
.DISCLAIMER The sample scripts are not supported under any Microsoft standard support program or service. The
sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties
including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire
risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall
Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any
damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of
business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or
documentation, even if Microsoft has been advised of the possibility of such damages. #>

Function Get-AppVPublishingTime($ClientName) {

# Sets the return hashtable

[hashtable]$Return = @{}

# Get the used event-logs of the target machine


$EventLogs = Get-WinEvent -LogName "Microsoft-AppV-Client/Operational" -ComputerName "$ClientName" | Where-
Object {$_.ID -eq "19001" -or $_.ID -eq "19002"}

# Get the latest publishing time


Foreach ($Item in ($EventLogs | Where-Object {$_.ID -eq 19001})) { If ($Time -le $Item.TimeCreated) {$LastPublishTime
= $Item} $Time = $Item.TimeCreated }

# get the latest publishing finished time


Foreach ($Item in ($EventLogs | Where-Object {$_.ID -eq 19002})) { If ($Time -le $Item.TimeCreated)
{$LastPublishDoneTime = $Item} $Time = $Item.TimeCreated }

# If the last publish time is higher than the done time no result will be returned

If ($LastPublishTime.TimeCreated -le $LastPublishDoneTime.TimeCreated) { $PublishTime =


$LastPublishDoneTime.TimeCreated - $LastPublishTime.TimeCreated }

# Add entries to return hashtable

$Return.LastPublishTime = $LastPublishTime.TimeCreated
$Return.ComputerName = $ClientName
$Return.PublishTime = $PublishTime.TotalSeconds

# Return data

Return $Return
}

$PublishedData = Get-AppVPublishingTime ComputerName


$PublishedData

#End of script

How to enumerate the registry of APPV packages

$package = "alter"

$pkgid = Get-AppvClientPackage | ? {$_.Name -like "*$package*"}

#Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\AppV\Client\Packages\$pkgid\Versions -Recurse -EA


SilentlyContinue | ft Name, SubKeyCount, ValueCount -AutoSize

Get-ChildItem -Path
HKLM:\SOFTWARE\Microsoft\AppV\Client\Packages\$($pkgid.PackageId)\Versions\$($pkgid.VersionId)\REGISTRY\
Recurse | Out-GridView -ErrorAction SilentlyContinue

#End of script

How to extract files from an APPV file

<# .DISCLAIMER The sample scripts are not supported under any Microsoft standard support program or service. The
sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties
including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire
risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall
Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any
damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of
business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or
documentation, even if Microsoft has been advised of the possibility of such damages. #>
If ("$env:temp\AppxManifest.xml") {remove-item "$env:temp\AppxManifest.xml" -Force}

[STRING]$Zipfile = "C:\v-AlteryxDesigner_1.02\v-AlteryxDesigner_1.02.appv"
[STRING]$Filename = "AppxManifest.xml"
[STRING]$Destination = "$env:temp"
[STRING]$FILELOCATION = "$Destination\$Filename"

[Reflection.Assembly]::LoadWithPartialName( "System.IO.Compression.FileSystem" ) > Out-Null


$ZIPSTREAM = [System.IO.Compression.ZipFile]::OpenRead($Zipfile)
$FILESTREAM = New-Object IO.FileStream ($FILELOCATION) ,'Append','Write','Read'

foreach ($ZIPPEDFILE in $ZIPSTREAM.Entries)


{
if ($ZIPPEDFILE.Name -eq $Filename)
{
$FILE = $ZIPPEDFILE.Open()
$FILE.CopyTo($FILESTREAM)
$FILE.Close()
}
}
$FILE.Close()
$FILESTREAM.close()

[xml]$xml = Get-Content $FILELOCATION


Write-Host ""
Write-Host "Package:" $xml.Package.Properties.DisplayName
Write-Host "COM Mode:" $xml.Package.ExtensionsConfiguration.COM.Mode
$xml.Package.ExtensionsConfiguration.COM.IntegratedCOMAttributes

#End of script

How to show information from the manifest.xml file in an APPV package

There are two main XML files that contain the information about both COM and Object setting and they are included in
the Package Catalog:

%PROGRAMDATA%\Microsoft\AppV\Client\Catalog\Packages

If the Package is published globally you will see two extra files “UserManifest.xml” and
“UserDeploymentConfiguration.xml” which are created when a package is published globally.

https://technet.microsoft.com/en-us/itpro/mdop/appv-v5/application-publishing-and-clientinteraction?
f=255&MSPPError=-2147217396#bkmk-files-data-storage

If you open either XML file, the COM or Objects settings may not be set as there is an OOS (Out of Sequencer)
experience where you haven’t checked any of the advanced options on the sequencer i.e.

This will give the package the following settings:

COM Mode: Isolated


COM Mode OutOfProcess: true
COM Mode InProcess: false
Objects: true

If you set the values on the advanced tab of the sequencer, then obviously the default OOS settings are changed.
The changed values are then updated in the Manifest.xml or UserManifest.xml (dependent upon whether the package is
published globally or not). Within the “.appv” package itself the file that gets updated is the AppxManifest.xml.

But the sequencer also updates the _DeploymentConfig.xml file to have the same values:
<# .DISCLAIMER The sample scripts are not supported under any Microsoft standard support program or service. The
sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties
including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire
risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall
Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any
damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of
business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or
documentation, even if Microsoft has been advised of the possibility of such damages. #>

########################################
# Function Check-AppVClientPackages
########################################

Function Check-AppVClientPackages(){

$PKGS = Get-AppvClientPackage -all | sort Name

$Results_PC = @()

foreach($PKG in $PKGs){

$Package_Name = $PKG.Name
$Package_PID = $PKG.PackageId
$Package_VID = $PKG.VersionId
$Package_IPG = $PKG.IsPublishedGlobally
$Package_V = $PKG.Version
$Package_DCP = $PKG.GetDynamicDeploymentConfigurationPath()

$Result_PC = New-Object System.Object


$Result_PC | Add-Member -MemberType NoteProperty -Name Name -Value $Package_Name
$Result_PC | Add-Member -MemberType NoteProperty -Name PackageId -Value $Package_PID
$Result_PC | Add-Member -MemberType NoteProperty -Name VersionId -Value $Package_VID
$Result_PC | Add-Member -MemberType NoteProperty -Name Version -Value $Package_V
$Result_PC | Add-Member -MemberType NoteProperty -Name IsPublishedGlobally -Value $Package_IPG

# DeploymentConfiguration.xml

[xml]$ManConDP = gc $Package_DCP

$DP_Objects = $ManConDP.DeploymentConfiguration.UserConfiguration.Subsystems.Objects.Enabled
$DP_COM_Mode = $ManConDP.DeploymentConfiguration.UserConfiguration.Subsystems.COM.Mode
$DP_COM_OutP =
$ManConDP.DeploymentConfiguration.UserConfiguration.Subsystems.COM.IntegratedCOMAttributes.OutOfProcessEna
bled
$DP_COM_InP =
$ManConDP.DeploymentConfiguration.UserConfiguration.Subsystems.COM.IntegratedCOMAttributes.InProcessEnable
d

# AppxManifest.xml

$Package_Dir = [io.path]::GetDirectoryName($Package_DCP)

if($Package_IPG -eq $true){

$Package_Man = "$Package_Dir\UserManifest.xml"
}

elseif($Package_IPG -eq $false){


$Package_Man = "$Package_Dir\Manifest.xml"

[xml]$ManConAppx = gc $Package_Man

$Appx_Objects = ($ManConAppx.Package.Extensions.Extension | ? { $_.Category -eq "AppV.Objects" }).Objects


$Appx_COM_Mode = $ManConAppx.Package.ExtensionsConfiguration.COM.Mode
$Appx_COM_OutP =
$ManConAppx.Package.ExtensionsConfiguration.COM.IntegratedCOMAttributes.OutOfProcessEnabled
$Appx_COM_InP = $ManConAppx.Package.ExtensionsConfiguration.COM.IntegratedCOMAttributes.InProcessEnabled

Clear-Variable Package_Man
Clear-Variable ManConDP
Clear-Variable ManConAppx

# Object Configuration

if($DP_Objects -eq $null -and $Appx_Objects -eq $null){

$Package_Objects = "true"
$Package_Objects_Set = "Default"

elseif($DP_Objects -ne $null){

$Package_Objects = $DP_Objects
$Package_Objects_Set = "DeploymentConfiguration"

elseif($Appx_Objects -ne $null){

$Package_Objects = $Appx_Objects
$Package_Objects_Set = "AppXManifest"

# COM Mode

if($DP_COM_Mode -eq $null -and $Appx_COM_Mode -eq $null){

$Package_COM_Mode = "Isolated"
$Package_COM_Set = "Default"

elseif($DP_COM_Mode -ne $null){


$Package_COM_Mode = $DP_COM_Mode
$Package_COM_Set = "DeploymentConfiguration"

elseif($Appx_COM_Mode -ne $null){


$Package_COM_Mode = $Appx_COM_Mode
$Package_COM_Set = "AppXManifest"

# COM Mode OutProcess

if($DP_COM_OutP -eq $null -and $Appx_COM_OutP -eq $null){

$Package_COM_OutP = "true"

elseif($DP_COM_OutP -ne $null){

$Package_COM_OutP = $DP_COM_OutP

elseif($Appx_COM_OutP -ne $null){

$Package_COM_OutP = $Appx_COM_OutP

# COM Mode InProcess

if($DP_COM_InP -eq $null -and $Appx_COM_InP -eq $null){

$Package_COM_InP = "false"

elseif($DP_COM_InP -ne $null){

$Package_COM_InP = $DP_COM_InP

elseif($Appx_COM_InP -ne $null){

$Package_COM_InP = $Appx_COM_InP

$Result_PC | Add-Member -MemberType NoteProperty -Name Objects -Value $Package_Objects


$Result_PC | Add-Member -MemberType NoteProperty -Name ObjectsSetBy -Value $Package_Objects_Set
$Result_PC | Add-Member -MemberType NoteProperty -Name COMMode -Value $Package_COM_Mode
$Result_PC | Add-Member -MemberType NoteProperty -Name COMModeSetBy -Value $Package_COM_Set
$Result_PC | Add-Member -MemberType NoteProperty -Name COMOutP -Value $Package_COM_OutP
$Result_PC | Add-Member -MemberType NoteProperty -Name COMInP -Value $Package_COM_InP

if($Package_Objects_Set -ne $null){ Clear-Variable Package_Objects_Set }


if($Package_COM_Set -ne $null){ Clear-Variable Package_COM_Set }

$Results_PC += $Result_PC
}

return $Results_PC

Check-AppVClientPackages

# End of script

The result will look something like this:

List folder items in APPV folder

First open the application in the APPV VE CMD Prompt (see above scripts) and type: powershell
Now PowerShell is running the APPV VE and you can run these useful commands:

Returns the total amount of files in the folder and subfolders (so you can do file compare from native to virtual)

(Get-Childitem c:\<path to folder> -recurse).Count

5. Deployment, User & Manifest script examples

Below are a few scripting examples for App-V 5 configuration files (DeploymentConfig, UserConfig and
AppxManifest files).

Installing a shim

<MachineScripts>
<AddPackage>
<Path>sdbinst.exe</Path>
<Arguments>/q "[{AppVPackageRoot}]\..\Scripts\ExampleFile.sdb"</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

Running a Powershell script

<MachineScripts>
<AddPackage>
<Path>powershell.exe</Path>
<Arguments>-ExecutionPolicy ByPass -WindowStyle Hidden -File "[{AppVPackageRoot}]\..\Scripts\
PowerShellFile.ps1"</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

Running a Powershell command

<MachineScripts>
<AddPackage>
<Path>powershell.exe</Path>
<Arguments>-ExecutionPolicy ByPass -WindowStyle Hidden -Command "&amp; { Get-EventLog -LogName
security }"</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

Running an EXE (For example, Powershell) without waiting for execution to complete

<MachineScripts>
<AddPackage>
<Path>cmd.exe</Path>
<Arguments>/c START "" "powershell.exe" -ExecutionPolicy ByPass -WindowStyle Hidden -File
"[{AppVPackageRoot}]\..\Scripts\runProcess.ps1"</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

Running a VBScript (via the CScript engine)

<MachineScripts>
<AddPackage>
<Path>cscript.exe</Path>
<Arguments>"[{AppVPackageRoot}]\..\Scripts\Cscript_File.vbs"</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

Running a VBScript (via the WScript engine)

<MachineScripts>
<AddPackage>
<Path>wscript.exe</Path>
<Arguments>"[{AppVPackageRoot}]\..\Scripts\VB_File.vbs"</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

Installing an MSI

<MachineScripts>
<AddPackage>
<Path>msiexec.exe</Path>
<Arguments>/i "[{AppVPackageRoot}]\..\Scripts\MSI_File.msi" /qb</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

Installing a Driver

<MachineScripts>
<AddPackage>
<Path>pnputil.exe</Path>
<Arguments>/i /a "[{AppVPackageRoot}]\..\Scripts\Driver_File.inf"</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

Adding a Registry String Value


<MachineScripts>
<AddPackage>
<Path>reg.exe</Path>
<Arguments>ADD HKLM\SOFTWARE\AshurstTestKey /f /v AshurstTestValue /t REG_SZ /d
AshurstTestData</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

Giving Modify Permission to a Directory

<MachineScripts>
<AddPackage>
<Path>icacls.exe</Path>
<Arguments>"C:\AshurstTest" /grant Users:(OI)(CI)(M) /C /Q</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

Creating a Symbolic Link (Running a windows command shell internal command – see here)

<MachineScripts>
<AddPackage>
<Path>cmd.exe</Path>
<Arguments>/C MKlink /D C:\Ashurst "C:\Program Files\AAshurst"</Arguments>
<Wait RollbackOnError="true" Timeout="30"/>
</AddPackage>
</MachineScripts>

6. Measuring Disk Performance

Download Diskspd.exe from here: https://gallery.technet.microsoft.com/DiskSpd-a-robust-storage6cd2f223/file/


152702/1/Diskspd-v2.0.17.zip

Download CreateFile.exe from here: http://www.adaptivasupport.com/downloads/CreateFile.exe

Extract, copy and paste them in your tools folder: C:\Tools

Run elevated from PowerShell console:

<# .DISCLAIMER The sample scripts are not supported under any Microsoft standard support program or service. The
sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties
including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire
risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall
Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any
damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of
business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or
documentation, even if Microsoft has been advised of the possibility of such damages. #>

# Use CreateFile.exe to create the file


$BenchmarkFile="C:\Tools\Benchmarkfile.dat"
C:\Tools\CreateFile.exe $BenchmarkFile (50GB)

# Using 8 threads of execution, each generating 8 outstanding random 8KB unbuffered read IOs #
PLEASE AMEND THE <architecture> in the path below before running script!!!

C:\Tools\Diskspd-v2.0.17\<architecture>\DiskSpddiskspd.exe -c1G -d10 -r -w0 -t8 -o8 -b8K -h -L $BenchmarkFile

#End of script

Parameter Description Notes


-c Size of file used. Specify the number of bytes or use suffixes like K, M or G (KB, MB, or GB). You should
use a large size (all of the disk) for HDDs, since small files will show unrealistically high
performance (short stroking).
-d The duration of the You can use 10 seconds for a quick test. For any serious work, use at least 60 seconds.
test, in seconds.
-w Percentage of 0 means all reads, 100 means all writes, 30 means 30% w
writes.

For more detailed information, go to https://blogs.technet.microsoft.com/josebda/2014/10/13/diskspd -powershelland-


storage-performance-measuring-iops-throughput-and-latency-for-both-local-disks-and-smb-file-shares/

You might also like