Detect App-V publishing timed out

23 Mar 2015 by Ryan Ververs-Bijkerk

Category:

    App-V

Detect App-V publishing timed out

Table of Content

  • Complete code:

During the European App-V User Group 2015 I presented a session about a new product called Login PI. This session was all about how to use Login PI to monitor the user experience and availability of App-V delivered applications. This presentation will be published in the upcoming weeks. In the product demo I used a script to verify if publishing has timed out. Within this blog post I will share how to check if the App-V publishing has timed out with powershell.

The publishing stop Event has ID 19002 and is located in “Applications and Services Logs\Microsoft\App-V\Client\Operational”. The 19002 event contains a messages with a return code as you can see in the following picture.

event-id-19002

The first step is to collect the event by powershell. Please note: In this example only the first result is selected.

$endEvent = Get-WinEvent -LogName "Microsoft-AppV-Client/Operational" | Where-Object {$_.ID -eq "19002"} | Select -First 1

By running the above command the event is stored in the $endEvent variable. The next step is to collect the return code from the event message. By using the regex command we can return the line which contains the return code. We can filter the value so we have the exit code.

$endEventMessage = $endEvent.Message
$endEventCode = [regex]::match($endEventMessage, "(.*)Return.*$", "Multiline")

$endEventCharPos = $endEventCode.Value.IndexOf("-")
$endEventCode = $endEventCode.Value.Substring($endEventCharPos +1) -replace " ", ""

The $endEventCode can be used to check if the publishing has timed out as shown in the following if statement.

if ($endEventCode -eq "0x80072EE2")
{
	Write-host "The operation timed out"
} elseif ($endEventCode -eq "0x0")
{
	Write-Host "App-V Publishing is done"
} else
{
	Write-Host "Unknown exit code: $endTimeCode"
}

This way you can notify an user something went wrong during publishing and the applications are not delivered. If you have questions or a comment please leave them below.

Complete code:

$endEvent = Get-WinEvent -LogName "Microsoft-AppV-Client/Operational" | Where-Object {$_.ID -eq "19002"} | Select -First 1

$endEventMessage = $endEvent.Message
$endEventCode = [regex]::match($endEventMessage, "(.*)Return.*$", "Multiline")

$endEventCharPos = $endEventCode.Value.IndexOf("-")
$endEventCode = $endEventCode.Value.Substring($endEventCharPos +1) -replace " ", ""

if ($endEventCode -eq "0x80072EE2")
{
	Write-host "The operation timed out"
} elseif ($endEventCode -eq "0x0")
{
	Write-Host "App-V Publishing is done"
} else
{
	Write-Host "Unknown exit code: $endTimeCode"
}
Tags:
    microsoft
    app-v
    powershell
Ryan Ververs-Bijkerk
Written by Ryan Ververs-Bijkerk

Ryan is a self-employed technologist at GO-INIT who specializes in the EUC and code area. He primarily focuses on the user experience in centralized desktop environments.

Search

    Follow me

    Community