使用Powershell将文件上载到Sharepoint时出现突然错误

使用Powershell将文件上载到Sharepoint时出现突然错误,powershell,sharepoint,Powershell,Sharepoint,我正在使用Powershell将图像(

我正在使用Powershell将图像(<100kb)上载到SharePoint文档库。前30-40个文件上传得非常完美,但突然我收到了以下消息:

Exception calling "UploadFile" with "3" argument(s): "An exception occurred during a WebClient request." At D:\SP01\Scripts\E_Zeitkonto\PSURLCapture\PSURLCapture.ps1:153 char:26
+     $WebClient.UploadFile <<<< ($UploadFullPath, "PUT", $LocalPath)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

这里怎么了?我缺少什么?

当Uploadfile调用崩溃时,$UploadFullpath的值是多少?您可以使用Fiddler查看http端发生的情况吗?如果我不得不猜测(不知道
$UploadFullPath
的确切值),我会说您正在使用
Get ChildItem
获取文件并将其传递给函数。您可能遇到的一个问题是,如果使用
Get ChildItem
,它也会获取目录,当您传递目录时,它将不起作用。
Function UploadToSPPictureLib($LocalPath, $spDocLibPath) 
{
    $UploadFullPath = $spDocLibPath + "/" + $(split-path -leaf $LocalPath) 
    $WebClient = new-object System.Net.WebClient 
    $WebClient.Credentials = [System.Net.CredentialCache]::DefaultCredentials 
    $WebClient.UploadFile($UploadFullPath, "PUT", $LocalPath)

    $WebClient.Dispose()
}