Identify App-V 5 errors

App-V 5 has provided us with many granular logs to identify issues, but when troubleshooting there needs to be an overview of errors. For the last few days quite a lot of effort on my own part has been in browsing through the logs, so as opposed to manually traverse individual logs or filtering all of them we can leverage PowerShell to identify errors quite easily. The below piece of code will traverse all but one of the logs and quickly identify any errors.

#Nicke Källén – 2013-05-08
#Define App-V logs
$appvlogs = Get-WinEvent -ListLog *AppV* -Force
#Define start-time - suggested time yesterday
$starttime = (Get-Date).AddDays(-1)
#Define end-time - now
$endtime=[datetime]::Today
#Set Culture to en-US, otherwise Message goes blank
$orgCulture = Get-Culture
[System.Threading.Thread]::CurrentThread.CurrentCulture = New-Object "System.Globalization.CultureInfo" "en-US"

#Loop through all log-files
foreach ($log in $appvlogs) {
write-host “Log; ” $log.LogName
#Skip operational log as it most contains informational messages and is heavy
if ($log.Logname -ne "Microsoft-AppV-Client/Operational") {
#Select only errors (level = 2) and select time and message of the event
Get-WinEvent -FilterHashTable @{Logname=$log.LogName;starttime=$starttime;endtime=$endtime} -Oldest -ErrorAction SilentlyContinue| ?{$_.Level -eq "2"} | Format-List TimeCreated, Message
}}
# Reset Culture to orginal
[System.Threading.Thread]::CurrentThread.CurrentCulture = $orgCulture

Leave a Reply

Your email address will not be published. Required fields are marked *