Home > Software design >  Any restriction using Word COM objects in SSH session to Windows?
Any restriction using Word COM objects in SSH session to Windows?

Time:10-12

Can we use WinWord COM objects from PowerShell in an SSH session and what are the restrictions, if any?

Let's take an example. I have a PowerShell script which manipulates a Word file (link here if you really need it). This script works well when run inside a Windows session. However, when I am logged on the Windows system using SSH, same user as the Windows session, this script no longer works.

The meaningful initialisation sequence is:

$word = New-Object -ComObject Word.Application
$word.Visible = $False
$doc = $word.Documents.Open($DocIn)
$properties = $doc.CustomDocumentProperties

When the script is run in an SSH session, the document is correctly opened ($word and $doc are not $null). However, $properties is $null. This is not the case when the script is run inside a Windows session. So, we cannot say that using Word as COM object does not work since the document seems open (and a WINWORD.EXE process is created). But the behaviour is different and limited (useless in my case).

Any explanation? Any guidelines to use Word in PowerShell scripts outside a Windows session, from a remote session?

CodePudding user response:

Answer in a comment from @Toni, see https://support.microsoft.com/en-us/topic/considerations-for-server-side-automation-of-office-48bcfe93-8a89-47f1-0bce-017433ad79e2

In short, it is not possible to run automation scripts for Office using a server access connection (SSH or other).

  • Related