How to test the WordAutomationService

I got asked whether the WordAutomationService in SharePoint could be started tested somehow or started to view ULS-Logs while running the conversion.

I creade a script to start converting a document from SharePoint (the document must exist and be in one of the supported formats).

Tests the WordAutomationService by submitting a document and waiting for the results.
Url (in SharePoint) that points to the document to convert
This documents should exist.
Url (in SharePoint) to place the converted document
This documents should *not* exist.
Format of the output. PDF or XPS. Default: PDF
Test-WordAutomationService -InFile -OutFile
Converts to pdf and saves the result to
param (
[ValidateSet("pdf", "xps")]
[string]$Format = "pdf"
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$tmp = [Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Word.Server")
if($tmp -eq $null) {
throw "Could not load Microsoft.Office.Word.Server.dll. Somethong is not right..."
Write-Verbose "Assembly $($tmp.GetName().Name) is present and loaded"
$serviceApp = Get-SPServiceApplication | Where-Object { $_.TypeName -eq "Word Automation Services" } | Select-Object -First 1
if($null -eq $serviceApp) {
throw "Could not find Word Automation Services Service Application. Somethong is not right..."
Write-Verbose "Using Service-Application $($serviceApp.Name)."
#TODO: Service app as param? what if there's more than one?!
$serviceAppProxy = Get-SPServiceApplicationProxy | Where-Object { $_.ServiceEndpointUri -eq $serviceApp.Uri.AbsoluteUri }
Write-Verbose "Using Service-ApplicationProxy $($serviceAppProxy.Name)."
$web = $null
$url = $InFile
while ($null -eq $web) {
throw "could not find a viable web from url: $($InFile)"
$url = (Split-Path -Path $url -Parent).Replace("\", "/")
$web = Get-SPWeb $url -ErrorAction Ignore
Write-Verbose "Using web: $($web) ($($web.Url))"
$setting = New-Object "Microsoft.Office.Word.Server.Conversions.ConversionJobSettings"
$setting.OutputFormat = $Format.ToUpperInvariant()
$job = New-Object "Microsoft.Office.Word.Server.Conversions.ConversionJob" -ArgumentList @($serviceAppProxy.Id, $setting)
$job.UserToken = $web.CurrentUser.UserToken
$job.AddFile($InFile, $OutFile)
Write-Verbose "Started conversion-job with id: $($job.JobId)"
$timer = Get-SPTimerJob | Where-Object { $_.TypeName -like "Word Automation Services Timer Job" } | Select-Object -First 1
Start-SPTimerJob $timer
Write-Verbose "TimerJob '$($timer.DisplayName)' started."
$status = New-Object "Microsoft.Office.Word.Server.Conversions.ConversionJobStatus" -ArgumentList @($serviceAppProxy.Id, $job.JobId, $null);
while (($status.NotStarted -ge 1) -or ($status.InProgress -ge 1)) {
Write-Verbose "In Progress: $($status.InProgress)"
Start-Sleep -Seconds 1
$items = $status.GetItems("Succeeded,Failed,Canceled")
Write-Verbose "Job ended. $($items.Length) items in this job."
,($items) #write them...

The script will create a new conversion job for the WordAutomationService and start the corresponding TimerJob ("Word Automation Services Timer Job"). It will wait for the conversion to finish and output the results (inclunding errors).

Generally, if the WordAutomationService is not working as intended I consult the Troubleshooting Guideline.

(Remark: All links given refer to SharePoint 2010 - but all are still valid: WordAutomationService has not been changed (much).)