我创建了一个powershell脚本,目的是读取文本文档并将更改应用于sharepoint环境中的字段。对于技术术语中的任何错误我很抱歉,我刚开始并且还在学习。继承剧本:
$data = Get-Content "e:\projects.txt"
write-host $data.count total lines read from file
foreach ($line in $data)
{
write-host $line
$web = Get-SPWeb -Identity "http://bizprojectsqa.westerncape.gov.za/PWA/"
$list = $web.GetList($line)
$query = "<Where><Eq><FieldRef Name='Status'/><Value Type='Text'>(2)Active</Value></Eq></Where>"
$view = $list.Views["All Active Risks"]
$view.Query = $query
$view.Update();
}
下面是错误消息:
You cannot call a method on a null-valued expression.
At C:\temp\pwa_risks.ps1:12 char:13
+$view.Update <<<< ();
+CategoryInfo : InvalidOperation: (Update:String) [], RuntimeException
+FullyQualifiedErrorId : InvokeMethodNull
我认为它与$ view.Update()有关,但我不是100%肯定。