Archive for category Word Automation Services

PowerShell script to test Word Automations Services in SharePoint 2013

Troubleshooting Word Automation Service can be tricky. So I created a Powershell script til help you……..

1. Create and upload word document (ex. test.docx)

2.Change variables in script

3. Run script

#————————————————————————————————

# Test Word Automation Service for Sharepoint 2013

#————————————————————————————————

# 30-08-2014 Martin Bøjstrup

#

$AppName=“Word Automation Service Application”

$SiteUrl= http://team.domain.com

$WordDoc=“/Shared%20Documents/test.docx”

$PDF=“/Shared%20Documents/test.docx”

asnp  *sh*

Write-Host -BackgroundColor Green -ForegroundColor Yellow ” — Test Word Automation Service Instance— “

write-host “”

$WASinstance=Get-SPServiceInstance | ?{$_.typename -eq “Word Automation Services”}

IF ($WASinstance.Status -ne  “Online”)

{

    Write-Host -ForegroundColor Red -BackgroundColor White ” – Service Instance not started !! – Status: ” $WASinstance.Status

    Write-Host ”  – Run to start: (Get-SPServiceInstance | ?{$_.typename -eq “Word Automation Services”}).Provision()”

    break

}

Write-Host -ForegroundColor Green ”  – Service instance Online”

Write-Host -BackgroundColor Green -ForegroundColor Yellow ” — Test Word Automation Service Application — “

Write-Host “Check service application: “$AppName

$was=Get-SPServiceApplication -Name $AppName -ErrorAction SilentlyContinue

if (!$was)

{

    Write-Host -ForegroundColor Red -BackgroundColor White ” – Service application not found !!”

    break

}

Write-Host -ForegroundColor Green ”  – Service application found”

Write-Host -ForegroundColor Green ”  – Status : “$was.Status

Write-Host -BackgroundColor Green -ForegroundColor Yellow ” — Send convert job to Word Automation Service — “

Write-Host “Convert Word document to PDF : “$SiteUrl $WordDoc

[void][System.Reflection.Assembly]::LoadWithPartialName( “Microsoft.Office.Word.Server” )

 $ConvertJob = New-Object Microsoft.Office.Word.Server.Conversions.SyncConverter($AppName)

$ConvertJob.UserToken = (Get-SPWeb $SiteUrl).CurrentUser.UserToken

$ConvertJob.Settings.UpdateFields = $true

$ConvertJob.Settings.OutputFormat = “PDF”

$ConvertJob.Convert($SiteUrl+$WordDoc,$SiteUrl+$PDF);

Write-Host -ForegroundColor Green “— Test done —“

If job is failing with the this error I ULS – “Failed to launch sandbox process, SE_ASSIGNPRIMARYTOKEN_NAME and SE_INCREASE_QUOTA_NAME privileges are required

That means that service application pool account must have the SE_ASSIGNPRIMARYTOKEN_NAME and SE_INCREASE_QUOTA_NAME user rights to start processes.
To assign user rights to an account on the local computer

1.      From the Start menu, point to Administrative Tools, and then click Local Security Policy.

2.      In the Local Security Settings dialog box, double-click Local Policies, and then double-click User Rights Assignment.

3.      In the details pane, double-click Adjust memory quotas for a process. This is the SE_INCREASE_QUOTA_NAME user right.

4.      Click Add User or Group, and, in the Enter the object names to select box, type the user or group name to which you want to assign the user right, and then click OK.

5.      Click OK again, and then, in the details pane, double-click Replace a process level token. This is the SE_ASSIGNPRIMARYTOKEN_NAME user right.

6.      Click Add User or Group, and, in the Enter the object names to select box, type the user or group name to which you want to assign the user right, and then click OK.


1 Comment