Skip to content

Instantly share code, notes, and snippets.

@martin9700
Created February 27, 2014 13:50
Show Gist options
  • Save martin9700/9250381 to your computer and use it in GitHub Desktop.
Save martin9700/9250381 to your computer and use it in GitHub Desktop.
If ($Filter)
{ If ($Filter.ToUpper().IndexOf($Property.ToUpper()) -ge 0)
{ $Filter = $Filter.ToUpper().Replace($Property.ToUpper(),"`$Value")
Try {
[scriptblock]$Filter = [scriptblock]::Create($Filter)
}
Catch {
Write-Warning "$(Get-Date): ""$Filter"" caused an error, stopping script!"
Write-Warning $Error[0]
Exit
}
}
Else
{ Write-Warning "Could not locate $Property in the Filter, which is required. Filter: $Filter"
Exit
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment