s3调用powershell操作office时各种报错

as3调用powershell操作office时各种报错

我前边一共还提过三个问题都是指向这个问题的(悬赏75rmb),至今还未采纳,谁帮我解决了我回复您,您再去前面几个一起回复一下,我一并给您采纳了。
通过as3调用ps1脚本操作office,ps1脚本在A电脑上写的,内容也不复杂,不外乎就是对word和excel进行一些常见的操作(比如写数据,调整格式),已经在写代码的那台win7电脑A上测试过一切OK,但是拿到B,C,D电脑上就各种诡异报错,经过三天的排查,初步查出是powershell环境的问题。甚至连使用SaveAS命令都会报错。
比如,B电脑对下面这一步报错,

$selection.EndKey([Microsoft.Office.Interop.Word.WdUnits]::wdStory)

C电脑对下面这一句报错


```bash
$doc.SaveAs([ref]"C:\myMergeDoc.docx")


D电脑对下面这一句报错


```bash
$pdffile="C:\test.pdf"
$doc.SaveAs([ref] $pdffile, [ref] 17)

经过三天排查,怀疑是与powershell的环境有关,我分别在A(正常),B(不正常),C(正常)电脑运行了以下几个命令:

获得的信息如下:

A电脑可以正常运行

img

img

img

img

img

B电脑不能正常运行

img

img

img

img

C电脑能正常运行

img

img

img

img

img

img

DCOM也按照教程设置过了,ps1脚本文件的权限都设置过了,应该就是环境的问题了。
相信明眼人一眼就能看出B电脑缺了什么,我是PS小bai,请告诉我详细的解决步骤,先谢

以下是之前提问的请参考其中报错信息:


```bash
F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\myDoc.docx

参数1

C:/Users/Administrator/Documents/excel.tmp

参数2

F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A

dobeAIR\Versions\myResources\2023年3月12日

参数3

F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A

dobeAIR\Versions\thePapers\2023年3月12日\2023年3月12日12点37分36_秒测试报告.doc

x

参数4

F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A

dobeAIR\Versions\thePapers\2023年3月12日\2023年3月12日12点37分36_秒测试报告.pdf

参数5

2023年3月12日作业报告______①12点36分27秒—12点37分36秒______②耗时0时1分9秒;____

__③共测试3人

PS echo success

0002

F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A

dobeAIR\Versions\myResources\2023年3月12日

F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A

dobeAIR\Versions\myResources\2023年3月12日\朱熹_2023年3月12日12点37分22秒.docx

process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。

所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:47 字符: 32

+     $doc = $word.Documents.Open <<<< ([ref]$docxFile.FullName)

    + CategoryInfo          : NotSpecified: (:) [], MethodException

process error :    + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg

 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:48 字符: 24

+     $doc.Content.Select <<<< ()

    + CategoryInfo          : InvalidOperation: (Select:String) [], RuntimeExc 

process error :   eption

    + FullyQualifiedErrorId : InvokeMethodOnNull

 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:49 字符: 22

process error :+     $doc.Content.Copy <<<< ()

process error :    + CategoryInfo          : InvalidOperation: (Copy:String) [], RuntimeExcep 

process error :   tion

process error :    + FullyQualifiedErrorId : InvokeMethodOnNull

process error : 

process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自

 HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:50 字符: 15

process error :+     $doc.Close <<<< ()

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

process error :    + FullyQualifiedErrorId : DotNetMethodException

process error : 

process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:53 字符: 32

+     $doc = $word.Documents.Open <<<< ([ref]$outputFile)

    + CategoryInfo          : NotSpecified: (:) [], MethodException

process error :    + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg

 

F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A

dobeAIR\Versions\thePapers\2023年3月12日\2023年3月12日12点37分36_秒测试报告.doc

x

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:56 字符: 25

process error :+     $mySelection.HomeKey <<<< ([Microsoft.Office.Interop.Word.WdUnits]::wdSto

ry)   #光标移动到文首

process error :    + CategoryInfo          : InvalidOperation: (HomeKey:String) [], RuntimeEx 

process error :   ception

process error :    + FullyQualifiedErrorId : InvokeMethodOnNull

process error : 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:57 字符: 31

+     $mySelection.InsertNewPage <<<< ()    #插入空白页

process error :    + CategoryInfo          : InvalidOperation: (InsertNewPage:String) [], Run 

   timeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

process error : 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:58 字符: 25

+     $mySelection.HomeKey <<<< ([Microsoft.Office.Interop.Word.WdUnits]::wdSto

ry)   #插入空白页之后重新将光标移动到文首

process error :    + CategoryInfo          : InvalidOperation: (HomeKey:String) [], RuntimeEx 

process error :   ception

process error :    + FullyQualifiedErrorId : InvokeMethodOnNull

process error : 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:59 字符: 23

+     $mySelection.Paste <<<< ()

    + CategoryInfo          : InvalidOperation: (Paste:String) [], RuntimeExce 

process error :   ption

    + FullyQualifiedErrorId : InvokeMethodOnNull

 

process error :使用“0”个参数调用“Save”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 

process error :HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:60 字符: 14

process error :+     $doc.Save <<<< ()   #保存文档

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : DotNetMethodException

 

process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自

process error : HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:61 字符: 15

+     $doc.Close <<<< ()   #保存并关闭文档

process error :    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : DotNetMethodException

process error : 

F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A

dobeAIR\Versions\myResources\2023年3月12日\杨炎_2023年3月12日12点36分46秒.docx

process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:47 字符: 32

+     $doc = $word.Documents.Open <<<< ([ref]$docxFile.FullName)

process error :    + CategoryInfo          : NotSpecified: (:) [], MethodException

    + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg

 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:48 字符: 24

+     $doc.Content.Select <<<< ()

process error :    + CategoryInfo          : InvalidOperation: (Select:String) [], RuntimeExc 

   eption

    + FullyQualifiedErrorId : InvokeMethodOnNull

 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:49 字符: 22

+     $doc.Content.Copy <<<< ()

process error :    + CategoryInfo          : InvalidOperation: (Copy:String) [], RuntimeExcep 

   tion

    + FullyQualifiedErrorId : InvokeMethodOnNull

 

process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自

 HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:50 字符: 15

+     $doc.Close <<<< ()

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : DotNetMethodException

process error : 

process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。

所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:53 字符: 32

process error :+     $doc = $word.Documents.Open <<<< ([ref]$outputFile)

    + CategoryInfo          : NotSpecified: (:) [], MethodException

    + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg

 

F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A

dobeAIR\Versions\thePapers\2023年3月12日\2023年3月12日12点37分36_秒测试报告.doc

x

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:56 字符: 25

process error :+     $mySelection.HomeKey <<<< ([Microsoft.Office.Interop.Word.WdUnits]::wdSto

process error :ry)   #光标移动到文首

    + CategoryInfo          : InvalidOperation: (HomeKey:String) [], RuntimeEx 

   ception

process error :    + FullyQualifiedErrorId : InvokeMethodOnNull

 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:57 字符: 31

process error :+     $mySelection.InsertNewPage <<<< ()    #插入空白页

    + CategoryInfo          : InvalidOperation: (InsertNewPage:String) [], Run 

   timeException

process error :    + FullyQualifiedErrorId : InvokeMethodOnNull

process error : 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:58 字符: 25

+     $mySelection.HomeKey <<<< ([Microsoft.Office.Interop.Word.WdUnits]::wdSto

process error :ry)   #插入空白页之后重新将光标移动到文首

    + CategoryInfo          : InvalidOperation: (HomeKey:String) [], RuntimeEx 

process error :   ception

    + FullyQualifiedErrorId : InvokeMethodOnNull

process error : 

process error :不能对值为空的表达式调用方法。

所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:59 字符: 23

+     $mySelection.Paste <<<< ()

process error :    + CategoryInfo          : InvalidOperation: (Paste:String) [], RuntimeExce 

process error :   ption

process error :    + FullyQualifiedErrorId : InvokeMethodOnNull

process error : 

process error :使用“0”个参数调用“Save”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 

process error :HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:60 字符: 14

process error :+     $doc.Save <<<< ()   #保存文档

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : DotNetMethodException

process error : 

process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自

process error : HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:61 字符: 15

+     $doc.Close <<<< ()   #保存并关闭文档

process error :    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : DotNetMethodException

process error : 

F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A

dobeAIR\Versions\myResources\2023年3月12日\葛洪_2023年3月12日12点37分3秒.docx

process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:47 字符: 32

process error :+     $doc = $word.Documents.Open <<<< ([ref]$docxFile.FullName)

process error :    + CategoryInfo          : NotSpecified: (:) [], MethodException

process error :    + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg

process error : 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:48 字符: 24

process error :+     $doc.Content.Select <<<< ()

process error :    + CategoryInfo          : InvalidOperation: (Select:String) [], RuntimeExc 

   eption

process error :    + FullyQualifiedErrorId : InvokeMethodOnNull

 

process error :不能对值为空的表达式调用方法。

所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:49 字符: 22

+     $doc.Content.Copy <<<< ()

    + CategoryInfo          : InvalidOperation: (Copy:String) [], RuntimeExcep 

   tion

    + FullyQualifiedErrorId : InvokeMethodOnNull

process error : 

process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自

process error : HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:50 字符: 15

process error :+     $doc.Close <<<< ()

process error :    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

process error :    + FullyQualifiedErrorId : DotNetMethodException

process error : 

process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:53 字符: 32

+     $doc = $word.Documents.Open <<<< ([ref]$outputFile)

    + CategoryInfo          : NotSpecified: (:) [], MethodException

process error :    + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg

 

F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\theCollection\A

dobeAIR\Versions\thePapers\2023年3月12日\2023年3月12日12点37分36_秒测试报告.doc

x

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:56 字符: 25

+     $mySelection.HomeKey <<<< ([Microsoft.Office.Interop.Word.WdUnits]::wdSto

process error :ry)   #光标移动到文首

    + CategoryInfo          : InvalidOperation: (HomeKey:String) [], RuntimeEx 

   ception

    + FullyQualifiedErrorId : InvokeMethodOnNull

process error : 

process error :不能对值为空的表达式调用方法。

所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:57 字符: 31

process error :+     $mySelection.InsertNewPage <<<< ()    #插入空白页

    + CategoryInfo          : InvalidOperation: (InsertNewPage:String) [], Run 

   timeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:58 字符: 25

+     $mySelection.HomeKey <<<< ([Microsoft.Office.Interop.Word.WdUnits]::wdSto

process error :ry)   #插入空白页之后重新将光标移动到文首

    + CategoryInfo          : InvalidOperation: (HomeKey:String) [], RuntimeEx 

   ception

process error :    + FullyQualifiedErrorId : InvokeMethodOnNull

 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:59 字符: 23

process error :+     $mySelection.Paste <<<< ()

process error :    + CategoryInfo          : InvalidOperation: (Paste:String) [], RuntimeExce 

   ption

    + FullyQualifiedErrorId : InvokeMethodOnNull

process error : 

process error :使用“0”个参数调用“Save”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 

process error :HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:60 字符: 14

+     $doc.Save <<<< ()   #保存文档

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

process error :    + FullyQualifiedErrorId : DotNetMethodException

process error : 

process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自

process error : HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:61 字符: 15

process error :+     $doc.Close <<<< ()   #保存并关闭文档

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

process error :    + FullyQualifiedErrorId : DotNetMethodException

 

process error :参数“1”不应为 System.Management.Automation.PSReference。请不要使用 [ref]。

所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:65 字符: 32

+     $doc = $word.Documents.Open <<<< ([ref]$outputFile)

    + CategoryInfo          : NotSpecified: (:) [], MethodException

    + FullyQualifiedErrorId : RefArgumentToNonRefParameterMsg

 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:67 字符: 24

+     $mySelection.EndKey <<<< ([Microsoft.Office.Interop.Word.WdUnits]::wdStor

y)   #光标移动到文首

process error :    + CategoryInfo          : InvalidOperation: (EndKey:String) [], RuntimeExc 

   eption

process error :    + FullyQualifiedErrorId : InvokeMethodOnNull

 

process error :不能对值为空的表达式调用方法。

所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:68 字符: 31

process error :+     $mySelection.TypeBackspace <<<< ()

    + CategoryInfo          : InvalidOperation: (TypeBackspace:String) [], Run 

process error :   timeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

 

process error :不能对值为空的表达式调用方法。

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:69 字符: 31

process error :+     $mySelection.TypeBackspace <<<< ()

process error :    + CategoryInfo          : InvalidOperation: (TypeBackspace:String) [], Run 

   timeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

process error : 

process error :使用“16”个参数调用“SaveAs”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来

process error :自 HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:72 字符: 16

+     $Doc.SaveAs <<<< ([ref] $pdffile, [ref] 17)

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : DotNetMethodException

 

process error :使用“16”个参数调用“SaveAs”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来

process error :自 HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

iteMyDoc.ps1:74 字符: 16

process error :+     $doc.SaveAs <<<< ([ref] $outputFile)

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

process error :    + FullyQualifiedErrorId : DotNetMethodException

process error : 

process error :使用“0”个参数调用“Save”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自 

process error :HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

process error :所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:75 字符: 14

+     $doc.Save <<<< ()   #保存文档

process error :    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

process error :    + FullyQualifiedErrorId : DotNetMethodException

 

process error :使用“3”个参数调用“Close”时发生异常:“被调用的对象已与其客户端断开连接。 (异常来自

 HRESULT:0x80010108 (RPC_E_DISCONNECTED))”

所在位置 F:\ludashi_clean_softs\UUUUUUU\备份2023年3月12日\2019高中人教版\bin\wr

process error :iteMyDoc.ps1:76 字符: 15

+     $doc.Close <<<< ()   #保存并关闭文档

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : DotNetMethodException

 

hi5f5t

导出Excel完成
罚抄单词
测试影片已终止。


```

坐等各位大佬(我也不懂)

参考GPT和自己的思路:这个问题可能有多种原因导致,以下是一些可能的解决方案:

1 检查 PowerShell 版本和 Office 版本是否兼容,尽可能升级到最新版本;
2 确保 PowerShell 中正确加载了 Office 组件,可以使用以下命令进行加载:

Add-Type -AssemblyName Microsoft.Office.Interop.Word
Add-Type -AssemblyName Microsoft.Office.Interop.Excel

3 检查目标电脑上的 Office 是否安装了必要的组件,例如 "Microsoft Office Object Library";
4 确保在使用 $doc.SaveAs() 命令时,文件路径是存在的且有写入权限;
5 确保 PowerShell 执行策略(Execution Policy)允许执行脚本,可以尝试将策略设置为 RemoteSigned 或 Unrestricted;
6 如果在远程计算机上执行 PowerShell 脚本时出现问题,可以尝试启用远程 PowerShell,可以使用以下命令进行启用:

Enable-PSRemoting -Force

7 如果问题仍然存在,可以尝试使用 Process Monitor 等工具进行进一步的排查和分析。
希望这些解决方案能够帮助您解决问题。

基于bing、GPT部分内容和本人思考总结:
在使用S3调用PowerShell操作Office时,可能会遇到各种错误。以下是一些常见的错误及其解决方法:

“The term 'Connect-MsolService' is not recognized as the name of a cmdlet”错误
这个错误通常是由于缺少必要的PowerShell模块所致。解决方法是在PowerShell中执行以下命令:

plaintext
Copy code
Install-Module -Name MSOnline

这将安装Microsoft Online Services Sign-In Assistant和Azure Active Directory PowerShell模块。
2. “The term 'New-Object' is not recognized as the name of a cmdlet”错误
这个错误通常是由于PowerShell版本不兼容所致。解决方法是将PowerShell版本升级到4.0或更高版本。
3. “The term 'Get-Mailbox' is not recognized as the name of a cmdlet”错误
这个错误通常是由于未加载必要的Exchange PowerShell模块所致。解决方法是在PowerShell中执行以下命令:

plaintext
Copy code
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010

这将加载Exchange 2010 PowerShell模块。
4. “The term 'Invoke-Command' is not recognized as the name of a cmdlet”错误
这个错误通常是由于未加载必要的PowerShell Remoting模块所致。解决方法是在PowerShell中执行以下命令:

plaintext
Copy code
Enable-PSRemoting

这将启用PowerShell Remoting功能,并加载必要的模块。
5. “The term 'Set-ExecutionPolicy' is not recognized as the name of a cmdlet”错误
这个错误通常是由于没有足够的权限来更改PowerShell执行策略所致。解决方法是以管理员身份运行PowerShell,并执行以下命令:

plaintext
Copy code
Set-ExecutionPolicy RemoteSigned

这将允许运行本地脚本和远程签名的脚本。
希望这些解决方法可以帮助你解决问题。如果问题仍然存在,请提供更多详细信息,我可以帮助你更好地解决问题。