运行远程PowerShell Office卸载脚本

运行远程PowerShell Office卸载脚本,powershell,windows-update,Powershell,Windows Update,KB2956128让我的网络中的用户头疼。我没有在这个环境中运行WSUS,所以我打算使用PS脚本来完成卸载。 无论如何,下面的脚本应该可以工作 $comp='PC03' $scrblock= { $TitlePattern='KB2956128' $Session=新对象-ComObject Microsoft.Update.Session $Collection=新对象-ComObject Microsoft.Update.UpdateColl $Installer=$Session.Crea

KB2956128让我的网络中的用户头疼。我没有在这个环境中运行WSUS,所以我打算使用PS脚本来完成卸载。 无论如何,下面的脚本应该可以工作

$comp='PC03' $scrblock= { $TitlePattern='KB2956128' $Session=新对象-ComObject Microsoft.Update.Session $Collection=新对象-ComObject Microsoft.Update.UpdateColl $Installer=$Session.CreateUpdateInstaller $Searcher=$Session.CreateUpdateSearcher $Searcher.QueryHistory0,$Searcher.GetTotalHistoryCount | 其中对象{$\ Title-匹配$TitlePattern}| ForEach对象{ 写入找到的详细更新历史记录条目$$\uTitle $SearchResult=$Searcher.SearchUpdateID='$$\.UpdateID.UpdateID'和RevisionNumber=$$$\.UpdateID.RevisionNumber 写入发现的详细$$SearchResult.Updates.Count更新条目 如果$SearchResult.Updates.Count-gt 0{ $Installer.Updates=$SearchResult.Updates $Installer.Uninstall $Installer |选择对象-属性ResultCode、RebootRequested、异常 结果代码:http://technet.microsoft.com/en-us/library/cc720442WS.10.aspx } } } 调用命令-ComputerName$comp-ScriptBlock$scrblock-Credential'myDomain\administrator' 相反,我得到了这个错误

使用0个参数调用CreateUpdateInstaller时出现异常:访问被拒绝。来自HRESULT的异常:0x80070005 E_访问被拒绝 +CategoryInfo:NotSpecified::[],MethodInvocationException +FullyQualifiedErrorId:CommMethodTargetInvocation +电脑名称:PC03 使用2个参数调用QueryHistory时发生异常:来自HRESULT的异常:0x80240007 +CategoryInfo:NotSpecified::[],MethodInvocationException +FullyQualifiedErrorId:CommMethodTargetInvocation +电脑名称:PC03 我不太明白为什么访问被拒绝。有什么想法吗?

简短的回答是,可以远程调用。您只能在本地执行此操作,不能通过会话或任何其他远程处理。但是,您可以使用psexec作为系统远程执行脚本