Powershell for SharePoint>&燃气轮机;抓住我们!rd错误

Powershell for SharePoint>&燃气轮机;抓住我们!rd错误,powershell,sharepoint-2010,Powershell,Sharepoint 2010,我在这段代码中不断遇到以下错误: #Setup default variables $webUrl = Get-SPWeb -Identity "http://CiscoIntranet/sites/VOIP" $list = $webUrl.GetList("http://CiscoIntranet/sites/VOIP/ForwardTech") [System.Reflection.Assembly]::LoadWithPartialName(”Microsoft.SharePoint”)

我在这段代码中不断遇到以下错误:

#Setup default variables
$webUrl = Get-SPWeb -Identity "http://CiscoIntranet/sites/VOIP"
$list = $webUrl.GetList("http://CiscoIntranet/sites/VOIP/ForwardTech")
[System.Reflection.Assembly]::LoadWithPartialName(”Microsoft.SharePoint”) 

function ProcessMove {
   param($folderUrl)
   $folder = $web.GetFolder($folderUrl)
        foreach ($file in $folder.Files)
            {
                [Microsoft.SharePoint.SPFile]$spFile = $file;           
                $docset=$($file.Counterparty2);
                $destinationFolderUrl = "http://CiscoIntranet/sites/VOIP/ForwardTech/" + $docset;               
                $spFile.MoveTo($destinationFolderUrl + $file.Name, $true);
                $webUrl.Update();
            }
}
#Move root Files
ProcessMove($list.RootFolder.Url)

You cannot call a method on a null-valued expression.
At C:\PS\MoveFiles.ps1:8 char:28
+    $folder = $web.GetFolder <<<< ($folderUrl)
    + CategoryInfo          : InvalidOperation: (GetFolder:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Method invocation failed because [Microsoft.SharePoint.SPListItemCollection] doesn't contain a method named 'MoveTo'.
At C:\PS\MoveFiles.ps1:13 char:23
+                 $list.Items.MoveTo <<<< ($destinationFolderUrl + $file.Name, $true);
    + CategoryInfo          : InvalidOperation: (MoveTo:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound
#设置默认变量
$webUrl=获取SPWeb-标识“http://CiscoIntranet/sites/VOIP"
$list=$webUrl.GetList(“http://CiscoIntranet/sites/VOIP/ForwardTech")
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
函数ProcessMove{
参数($folderUrl)
$folder=$web.GetFolder($folderUrl)
foreach($folder.Files中的文件)
{
[Microsoft.SharePoint.SPFile]$SPFile=$file;
$docset=$($file.Counterparty2);
$destinationFolderUrl=”http://CiscoIntranet/sites/VOIP/ForwardTech/“+$docset;
$spFile.MoveTo($destinationFolderUrl+$file.Name,$true);
$webUrl.Update();
}
}
#移动根文件
ProcessMove($list.RootFolder.Url)
不能对空值表达式调用方法。
在C:\PS\MoveFiles.ps1:8 char:28

+$folder=$web.GetFolder这是工作代码

$siteURL="http://CiscoIntranet/sites/VOIP"
$docLib = "ForwardTech"
$site=Get-SPSite $siteURL
$web=$site.RootWeb
$collFiles=$web.GetFolder($docLib).Files
$count=$collFiles.Count
while($count -ne 0)
{
$item = $collFiles[$count-1].Item
$DocSet = $item["Region"]
Write-Host "$DocSet is the doc set. $collFiles[$count-1].Name is name"
$collFiles[$count-1].MoveTo($siteURL + "/" + $docLib + "/" + $DocSet + "/"  + $collFiles[$count-1].Name, $true)                       
$count--
}

错误很明显<代码>$web
未知。你的意思是要有
$webUrl
?@Manojlds:也许你是对的。我会再试一次。。。谢谢。可能是重复的不是重复的,Richard被要求发布一个单独但相关的问题。