Create and upload word document (test.docx) to http://team.domain.com/Shared%20Documents
Run script
#------------------------------------------------------------------------------------------------
# Test Word Automation Service
#------------------------------------------------------------------------------------------------
# 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.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 : Word Automation Service Application"
Start-SPTimerJob "Word Automation Service Application"
Write-Host "Job status:"
new-object Microsoft.Office.Word.Server.Conversions.ConversionJobStatus($AppName, $job.JobId,$null);
Write-Host ""
Write-Host -ForegroundColor Green "--- Test done ---"
Function ListConversionsStatus
{
$AppName="Word Automation Service Application"
[void][System.Reflection.Assembly]::LoadWithPartialName( "Microsoft.Office.Word.Server" )
$WASAllJobs=[Microsoft.Office.Word.Server.Conversions.ConversionJobStatus]::GetAllJobs($AppName, $null)
foreach ($WASJob in $WASAllJobs)
{
$WASJob
new-object Microsoft.Office.Word.Server.Conversions.ConversionJobStatus($AppName, $WASJob.JobId,$null);
}
}
Write-Host ""
Write-Host -ForegroundColor Green "List all conversion jobs : run command: ListConversionsStatus"
Ingen kommentarer:
Send en kommentar