Skip to content

Instantly share code, notes, and snippets.

@SBajonczak
Created June 12, 2016 06:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Test the convertion of documents with WAS in SharePoint
$AppName=“Word Automation Services”
$timerJobName=“Word Automation Services”
$SiteUrl=“http://portal.contoso.com”
$WordDoc=“/Freigegebene%20Dokumente/Fdsfsfd.docx”
$PDF=“/Freigegebene%20Dokumente/test.pdf”
asnp *sh*
Write-Host -BackgroundColor Green -ForegroundColor Yellow “ — Test Word Automation Service — ”
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 -BackgroundColor Green -ForegroundColor Yellow ” — Test Word Automation Service Application — “
write-host ”“
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 “Convert Word document to PDF : ”$SiteUrl $WordDoc
[void][System.Reflection.Assembly]::LoadWithPartialName( “Microsoft.Office.Word.Server” )
$jobSettings = New-Object Microsoft.Office.Word.Server.Conversions.ConversionJobSettings
$jobSettings.OutputFormat = “PDF”
$job = New-Object Microsoft.Office.Word.Server.Conversions.ConversionJob( $AppName, $jobSettings )
$job.UserToken = (Get-SPWeb $SiteUrl).CurrentUser.UserToken
$job.AddFile($SiteUrl+$WordDoc,$SiteUrl+$PDF)
$job.Name=“TEST JOB !!!!!!!”
$job.Start( )
Write-Host “”
Write-Host “Starting Timer job : ” $timerJobNameget-sps
Start-SPTimerJob $timerJobName
Write-Host “Job status:”
new-object Microsoft.Office.Word.Server.Conversions.ConversionJobStatus($AppName, $job.JobId,$null);
Write-Host “”
Write-Host -ForegroundColor Green “— Test done —”
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment