title: Powershell v3 Isfilter unnamed script block.
body: <p>The following code snipit works in PowerShell v2, but not v4.. In the release notes for PowerShell v3 is explains that you cannot set the IsFilter property on an unnamed script block. I believe that's exactly what I have, but I don't understand what change to make.. </p>
  
  <p>Any help would be appreciated. </p>
  
  <pre><code>function Stop-WindowsService 
  {
      param(
          [Parameter(Mandatory=$true,ValueFromPipeline=$true)]
          $fromPipe,
          [Parameter(ParameterSetName='static',Mandatory=$true,Position=0)]
          [ValidateNotNullOrEmpty()]
          [string]$name,
          [Parameter(ParameterSetName='dynamic',Mandatory=$true,Position=0)]
          [ValidateNotNull()]
          [ScriptBlock]$scriptReturningName,
          [Parameter(Mandatory=$false)]
          [ValidateRange(1,86400)]
          [int]$timeout = 60
      )
  
  Process {        
      $server = $_
      if($PsCmdlet.ParameterSetName -eq 'dynamic') {
          $scriptReturningName.IsFilter = $true
          $name = ($server | &amp;$scriptReturningName)
      }        
      Write-Verbose "$($server.Name): $name ==&gt; Checking"
      $service = $server | Get-WindowsServiceRaw $name
  </code></pre>