Thursday, August 11, 2016

XenApp - Print Spooler Failed to Install Driver - Part 2


Last week, we looked at some sporadic issues with Printing in XenApp. We managed to identify what the issue, and have found some potential causes. Now we are going to dive into this a bit more, and attempt to find a solution

In order to do this, we are going to need to gather more data. Since I  discovered this issue after it was escalated to me, I soon found out this has been a long standing problem. After some quick digging through event logs, I was able to determine that this issue is occurring frequently, but I have been unable to determine a pattern.

I patched together this quick script to scrape all of the servers in the XenApp farm daily, and place that information in an xml file in my reporting directory.

$filter = @{}
$filter.set_item("ID",(215,319))
$filter.add("LogName", "Microsoft-Windows-PrintService/Admin")
$date = (Get-Date).AddDays(-1)
$filter.Add("StartTime", $date)

$computers = Get-XAServer -OnlineOnly -ZoneName "Default Zone" | select -ExpandProperty ServerName
$list = @{}
foreach($computer in $computers){
    Write-Host -Foreground Yellow "Gathering Details from $computer"
    $obj= Get-WinEvent -ComputerName $computer -FilterHashtable $filter
    $list.Add($computer, $obj)

}

#Export The log

$ReportDirectory = ($env:userprofile) +"\Reports"
$day = (Get-Date).Day
$month = (Get-Date).Month
$hour = (Get-Date).Hour
$minute = (Get-Date).Minute
$filename = "print`-$month`-$day`-$hour`-$minute.xml"
$fullExportLocation = "$ReportDirectory\Print215\$filename"
Write-Host -ForegroundColor Cyan "Exporting object to $fullExportLocation"
$list | Export-Clixml -Path $fullExportLocation



I've created a scheduled task to run the above script on my PC. This assumes that you have the proper XenApp powershell cmdlets installed and working. To Verify your XenApp cmdlets are correctly setup, run Get-XAServer in powershell. If you see a list of XenApp servers, you are good to go.
It's best to set the task to run before the images refresh themselves. Our images are on a nightly refresh, so I set my script to run at 9pm.

You can examine the events at a later point in time by using the Import-CLIXml Cmdlet.

No comments:

Post a Comment