title: Jenkins: Convert .docx to .pdf issues
body: <p>We're trying to use Jenkins to convert a set of "Working Documents" into "Release Documents" when it builds out project. This involved taking the .docx files and saving them as .pdf files, which we accomplish with the following Powershell script:</p>
  
  <pre><code>$documents_path = "E:\Documentation\Working Documents\"
  
  $word_app = New-Object -ComObject Word.Application
  
  echo $word_app
  
  # This filter will find .doc as well as .docx documents
  $files = Get-ChildItem -Path $documents_path -Filter *.doc? 
  
  ForEach ($file in $files) {
      echo "Converting Document to PDF: $($file.FullName)"
  
      $document = $word_app.Documents.Open($file.FullName)
      $pdf_filename = "$($file.DirectoryName)\..\Release Documents\$($file.BaseName).pdf"
      $document.SaveAs([ref] $pdf_filename, [ref] 17)
      $document.Close()
  }
  
  $word_app.Quit()
  </code></pre>
  
  <p>Now, that script works 100% the way we expect when I log in to the Jenkins PC and run it myself in Powershell. However, when Jenkins tries running it we get <code>You cannot call a method on a null-valued expression</code> at <code>$document.SaveAs</code> and <code>$document.Close</code>.</p>
  
  <p>I assume this is because the user Jenkins runs as, <code>SYSTEM</code> does not have permission to access the .docx files, or can't find the Word installation, or something of that nature, but I can't think of how I should try to debug it further than this. Any tips are very much appreciated! </p>