title: How to write powershell script with Where-Object
body: <p>Given script like this :</p>
  
  <pre><code>Get-ADPermission -Identity "Mark Adam" | where {$._ExtendedRights -like "*Send-As*"} -and -not {$_.Users -like "NT AUTHORITY\SELF"}
  </code></pre>
  
  <p>Here I tried so far, still no luck.</p>
  
  <pre><code>var CommandGetAdPermission = new Command("Get-ADPermission");
  
  CommandGetAdPermission.Parameters.Add("Identity", Identity);       
  
  var CommandWhere = new Command("Where-Object");
  
  ScriptBlock filter = ScriptBlock.Create("{$_.ExtendedRights -like \"*Send-As*\"} -and -not {$_.User -like \"NT AUTHORITY\\SELF\"}");
  
  CommandWhere.Parameters.Add("FilterScript", filter);
  
  pipeline.Commands.Add(CommandGetAdPermission);
  pipeline.Commands.Add(CommandWhere);                     
  
  psh = pipeline.Invoke();
  errors = ps.Streams.Error.ReadAll();
  </code></pre>
  
  <p>Return error as below :</p>
  
  <blockquote>
    <p>The term 'Where-Object' is not recognized as the name of a cmdlet,
    function, script file, or operable program. Check the spelling of the
    name, or if a path was included, verify that the path is correct and
    try again.</p>
  </blockquote>
  
  <p>Do I do something wrong?</p>