Skip to content

Instantly share code, notes, and snippets.

@ArthurEzenwanne
Created May 2, 2019 15:50
Show Gist options
  • Save ArthurEzenwanne/068c084ea13f3752056e900479e35dea to your computer and use it in GitHub Desktop.
Save ArthurEzenwanne/068c084ea13f3752056e900479e35dea to your computer and use it in GitHub Desktop.
A gist to confirm that SharePoint Word Automation Service is working
# Path to original steps: https://absolute-sharepoint.com/2016/09/test-the-word-automation-service-application-with-powershell.html
# Confirm if this path is same on your env
Add-Type -Path 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.Office.Word.Server\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.Office.Word.Server.dll'
# Configure the job
$jobSettings = New-Object Microsoft.Office.Word.Server.Conversions.ConversionJobSettings
$jobSettings.OutputFormat = "PDF"
# Configure your word automation service name and credentials
$job = New-Object Microsoft.Office.Word.Server.Conversions.ConversionJob("Word Automation", $jobSettings)
$job.UserToken = (Get-SPWeb https://sharepoint.learn-sp2016.com).CurrentUser.UserToken
# Add location to file to convert
$job.AddFile("https://sharepoint.learn-sp2016.com/Shared%20Documents/Document1.docx", "https://sharepoint.learn-sp2016.com/Shared%20Documents/Document1-Final.pdf")
# Statrt the job
$job.Start()
Start-SPTimerJob "Word Automation"
# Monitor the job
new-object Microsoft.Office.Word.Server.Conversions.ConversionJobStatus("Word Automation", $job.JobId,$null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment