login vsi company logo login vsi company logo 250x40
header-03.jpg

Measure Microsoft App-V publishing time with Login PI

Measure Microsoft App-V publishing time with Login PI

Microsoft App-V is a great way to virtualize applications and publish them to the desktop. But App-V publishing can take some time and the application is not always available immediately. This can interfere with a Login PI workload. If the workload attempts to launch applications that haven’t been published to the desktop yet, this will result in application start timeouts reported by Login PI. In this blog post I will describe how to integrate App-V publishing in a Login PI workload.

By combining the script in this blog post with your Login PI workload, you will also be able to measure the App-V publishing time, receive reports about this in the Login PI web interface, and generate alerts and notifications when App-V publishing is not performing as expected.

Script for App-V publishing

With a PowerShell script we can make sure that the workload will wait until App-V publishing is done. By using Windows Forms within the PowerShell script we can detect this in the Login PI workload. In the end, Login PI will report how long it takes for publishing to take place from a user perspective.

The first step is to load the assembly for Windows Forms. This will be used for creating a form that will be detected by the workload.

# Load assembly
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null

Now we will need to store the current date and time within a variable to make sure that we collect the last start publishing event.

# Get current date / time
$currentTime = Get-Date

Next, we can create a loop that monitors the Windows Event Log looking for the last start publishing event with ID 19001.

# Collect App-V publishing startTime
Do
{
	$startTime = Get-WinEvent -LogName "Microsoft-AppV-Client/Operational" | Where-Object {$_.ID -eq "19001"} | Select -First 1
} While ($startTime.TimeCreated -gt $currentTime)
Write-Host "Start time:" $startTime.TimeCreated

This event indicates that publishing has started. Next we will have to wait until publishing is done. This is also done by using a while loop. When the publishing event with ID 19002 is found which contains a more recent date and time stamp as the start event, we can break out of the loop.

# Break variable for loop
$break = $False
# Do loop until publishing is done
Do
{	
	# Collect end of App-V publishing
	$endTime = Get-WinEvent -LogName "Microsoft-AppV-Client/Operational" | Where-Object {$_.ID -eq "19002"} | Select -First 1
	
	#Feedback
	Write-Host "End time:" $endTime.TimeCreated
	
	# If endTime is later then startTime break from loop
	If ($endTime.TimeCreated -gt $startTime.TimeCreated)
	{
		$break = $True
	} 
	else
	{
		Start-Sleep -Milliseconds 500
	}
} While ($break -eq $False)

To determine if publishing was successful we can use the same method that I recently published on my personal blog: Detect App-V publishing timed out.

# Collect end code to check if publishing has a timed out
$endTimeMessage = $endTime.Message
$endTimeCode = [regex]::match($endTimeMessage, "(.*)Return.*$", "Multiline")
$endTimeCharPos = $endTimeCode.Value.IndexOf("-")
$endTimeCode = $endTimeCode.Value.Substring($endTimeCharPos +1) -replace " ", ""

Based on the exit code a pop-up will appear so this can be detected by the Login PI workload.

if ($endTimeCode -eq "0x80072EE2")
{
	#Show popup for app_start of Login VSI or Login PI
	[System.Windows.Forms.Messagebox]::Show("The operation timed out", "Timeout")
} else
{
	#Show popup for app_start of Login VSI or Login PI
	[System.Windows.Forms.Messagebox]::Show("App-V Publishing is done", "App-V")
}

This script can be stored on the Login PI share. I created a directory named scripting on my share where I stored the script which is accessible for all Login PI users.

Workload integration

Login PI uses a text-based workload language which can be edited. This workload contains a prepare section which contains basic actions that needs to be done, like adding registry settings. Within the prepare phase we can add the script that we created in the previous step.

Open the workload file and add the following line on top of the prepare phase.

# Start App-V script for publishing time
App_Start("AppV", "", "Powershell.exe", "Title", "App-V", "", "-File %VSI_Share%\scripting\AppV.ps1")
App_Close("AppV", "Title", "App-V")

Configure the created workload within the workload settings and start the job. The workload engine will execute the script which is visible within the session.

measure microsoft app v publishing time with login pi script

Results

The engine will report the App-V publishing time by the workload action name "AppV" within the dashboard and the charts page.

measure microsoft app v publishing time with login pi dashboard

If the App-V publishing server is down for some reason, publishing will not take place and this will be reported by Login PI as a timeout. This timeout is visible within the dashboard and alerts page.

measure microsoft app v publishing time with login pi timeout

measure microsoft app v publishing time with login pi dashboard timeout

Conclusion

By using the script in this blog, it’s very easy to integrate App-V publishing time with Login PI. Now you will be able to receive reports about App-V publishing time in the Login PI web interface, and generate alerts and notifications when App-V publishing is not performing as expected. If you have any further questions or need any help to configure this, please feel free to contact us via the forums, or at support@loginvsi.com.

About the author

Ryan Bijkerk (@Logitblog) is a Product Owner at Login VSI and a Microsoft MVP on Application Virtualization (App-V) technology. He is also involved in the independent research Project VRC and speaks at events. Besides working, Ryan enjoys writing for his blog and riding his MTB.


Tags: How-to, Login PI, Microsoft, Application Virtualization, Monitoring, Best Practices, Support, Scripts

Start Delivering the Best End User Experience Today

Request a Demo

Login VSI, Inc.

3945 Freedom Circle
Suite 670
Santa Clara, CA 95054

Phone: +1 408 899 7418

Login VSI B.V.

De Entree 85
1101 BH Amsterdam
The Netherlands

Phone: +31 20 705 1200