Get App-V 5.x Publishing Time with PowerShell

02 Mar 2014 by Ryan Ververs-Bijkerk

Category:

    App-V

Get App-V 5.x Publishing Time with PowerShell

Table of Content

  • Where do we get the data from?
  • Stop-AppV-Publishing-Event
  • Powershell function

When publishing App-V 5.x applications it is interesting to know how long it takes to publish all applications. I needed this information during a large scale test to get a better understanding of the impact on the user experience. I also wanted to know if the publishing time increases when more users are active. This information can be used to optimize the publishing time and eventually the user experience.

In this blog post I will share a powershell function that can get the App-V publishing time on a remote specific machine.

Where do we get the data from?

With App-V 5.x the publishing events are logged in the event viewer. Event 19001 is the event which will indicate publishing has started. The time of this event is our starting point.

Start-AppV-Publishing-Event

Event 19002 is the closing event which indicates the publishing is finished.

Stop-AppV-Publishing-Event

Based on the time between the two events we can calculate the time during these events. This will result in the total publishing time of App-V.

Powershell function

With the following powershell function you can get the publishing time on a remote computer. The function will always get the latest publishing time.

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 return
	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
}

The text based version of the powershell function can be found here. Run the command as followed:

$PublishedData = Get-AppVPublishingTime W7-x86-AppV

The variable “PublishedData” contains the following information:

Powershell-PublishedData

$PublishedData.ComputerName - The computer name that is used as the parameter $PublishedData.PublishTime - The duration of the publishing the App-V applications in seconds $PublishedData.LastPublishTime - The date & time of the last publishing action

If the variable $PublishedData.PublishTime does not contain a value the publishing is probably not finished.

The powershell function can provide valuable information to get an overview of the App-V 5.x publishing time in your environment. If you have any questions or comments please leave a comment below.

Tags:
    microsoft
    app-v
    event viewer
    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