You cannot call a method on a null-valued expression (powershell, sharepoint)
<p>I created a powershell script with the purpose of reading a text document and applying changes to a field in a sharepoint environment. Sorry for any errors in technical jargon im just starting out and still learning. Heres the script:</p>

<pre><code>  $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 = "&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='Status'/&gt;&lt;Value Type='Text'&gt;(2)Active&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;"    
  $view = $list.Views["All Active Risks"]
  $view.Query = $query
  $view.Update();

 } 
</code></pre>

<p>Heres the error message:</p>

<pre><code> You cannot call a method on a null-valued expression.
 At C:\temp\pwa_risks.ps1:12 char:13
 +$view.Update &lt;&lt;&lt;&lt; ();
+CategoryInfo         : InvalidOperation: (Update:String) [], RuntimeException
 +FullyQualifiedErrorId : InvokeMethodNull
</code></pre>

<p>I think it has something to do with $view.Update() but im not 100% sure. </p>