Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
多文件上载错误无法对Phil Childs编写的空值表达式powershell脚本调用方法_Powershell - Fatal编程技术网

多文件上载错误无法对Phil Childs编写的空值表达式powershell脚本调用方法

多文件上载错误无法对Phil Childs编写的空值表达式powershell脚本调用方法,powershell,Powershell,我正在使用这个脚本 剧本 function Copy-FilestoSP { Param ( [parameter(Mandatory=$true)][string]$LocalPath, [parameter(Mandatory=$true)][string]$SiteUrl,

我正在使用这个脚本 剧本

                function Copy-FilestoSP
            {
                Param (
                       [parameter(Mandatory=$true)][string]$LocalPath, 
                       [parameter(Mandatory=$true)][string]$SiteUrl, 
                       [parameter(Mandatory=$true)][string]$Library, 
                       [parameter(Mandatory=$false)][string]$LibraryStartFolder, 
                       [parameter(Mandatory=$false)][string]$ManifestFilePath, 
                       [parameter(Mandatory=$false)][switch]$IncludeSubFolders,
                       [parameter(Mandatory=$false)][switch]$Approve,
                       [parameter(Mandatory=$false)][switch]$CheckIn,
                       [parameter(Mandatory=$false)][switch]$Overwrite,
                       [parameter(Mandatory=$false)][switch]$FlattenStructure
                       )

                try
                {

                #Get web and document library objects
                $web = Get-SPWeb $SiteUrl
                $docLibrary = $web.Lists[$Library]
                ---code skipped-----
当我调试时,我发现在获得SPWeb之后,我得到了

                You cannot call a method on a null-valued expression.
            At E:\BH\utility\Get-SPScripts.Copy-FilesToSP.ps1:331 char:21
            +         $web.Dispose <<<< ()
                + CategoryInfo          : InvalidOperation: (Dispose:String) [], RuntimeException
                + FullyQualifiedErrorId : InvokeMethodOnNull
我是这样执行的

Copy-FilestoSP -LocalPath "E:\files" -SiteUrl "http://sp2010" -Library "myDocuments" 

$web.Dispose()
->
如果($null ne$web){$web.Dispose()}
现在我只得到
脚本已停止,因为出现错误
Copy-FilestoSP -LocalPath "E:\files" -SiteUrl "http://sp2010" -Library "myDocuments"