使用PowerShell REMOTE

时间:2016-03-21 07:44:25

标签: powershell sharepoint sharepoint-2013

这个问题不只是关于使用PowerShell上传文档,而是关注“远程”。

我现在有两台服务器,

  1. 一个SharePoint场服务器
  2. 一个专门用于远程运行针对SharePoint场的脚本的任务服务器。
  3. 我们使用CredSSP进行身份验证,直到现在所有任务都运行良好,比如操作List / Item。但上传文件是阻止者。

    要上载的文件位于本地SharePoint服务器上。

    如果我直接在SharePoint服务器中运行

    ,invoke-command中的脚本块效果很好

    使用过的脚本:

    $credsspSession=New-PSSession -cn $SPServer-Authentication Credssp -Credential $credentail
    icm -session $credsspSession {
        Add-PSSnapin "Microsoft.sharepoint.powershell"
        $spweb=Get-SPWeb "https://siteURL"
        $file=Get-Item "filename"
        $spFolder=$spweb.GetFolder("FolderName")
        $fileCollection=$spFolder.Files
        $fileCollection.Add("FolderName/file.name",$file.OpenRead(),$false)
    
    }
    

    错误报道:

    PSMessageDetails      : 
    Exception             : System.Management.Automation.MethodInvocationException: Exception calling "Add" with "3" argument(s): "" ---> Microsoft.SharePoint.SPException
                               at Microsoft.SharePoint.SPFileCollection.Add(String urlOfFile, Stream file, Boolean overwrite, String checkInComment, Boolean checkRequiredFields)
                               at Microsoft.SharePoint.SPFileCollection.Add(String urlOfFile, Stream file, Boolean overwrite)
                               at CallSite.Target(Closure , CallSite , Object , String , Object , Boolean )
                               --- End of inner exception stack trace ---
                               at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
                               at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
                               at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                               at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    TargetObject          : 
    CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    FullyQualifiedErrorId : SPException
    ErrorDetails          : 
    InvocationInfo        : System.Management.Automation.InvocationInfo
    ScriptStackTrace      : at <ScriptBlock>, <No file>: line 9
    PipelineIterationInfo : {}
    PSComputerName        : fe0vm1074
    RunspaceId            : 3ca5166e-c28d-4dc5-a9f6-0d31091106f4
    

    对此有何想法?谢谢你的任何提示。

1 个答案:

答案 0 :(得分:0)

因此,这被认定为&#34;赛门铁克&#34;问题,它阻止我的远程PowerShell上传文件。 安装&#34; Symantec Patch&#34;(由Symantec提供,由我的同事安装)后,问题已解决。

相关问题