多文件上载错误无法对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"