3

I'm working on this script:

$criteria = @(
    @{Filter = "NotEquals"; Field = "_template"; Value = "{A87A00B1-E6DB-45AB-8B54-636FEC3B5523}"}  
)
$props = @{
    Index = "sitecore_master_index"
    Criteria = $criteria

}
Find-Item @props 

However I kept on getting this error:

Find-Item : Cannot bind parameter 'Criteria'. Cannot create object of type "Spe.Commands.Data.Search.SearchCriteria". Cannot convert value "NotEquals" to type "Spe.Commands.Data.Search.FilterType". Error: "Unable to match the identifier name NotEqual to a valid enumerator name.

I tried keywords for Filter such as: "Equals", "Equal", "NotContains" but still I kept getting the same error. Anynone could help me what's causing the issue? Basically I just want to exclude a certain items based on its templateid.

thanks

4

There is no NotEquals support for Filter.

But any condition can be negated if you use Invert = $true

$criteria = @(
    @{
        Filter = "Equals"; 
        Field = "_template"; 
        Value = "{A87A00B1-E6DB-45AB-8B54-636FEC3B5523}";
        Invert = $true;
    }  
)

I don't remember, maybe you need to lowercase and remove special chars from template ID: a87a00b1e6db45ab8b54636fec3b5523

There is more documentation about Find-Item here: https://doc.sitecorepowershell.com/appendix/indexing/find-item

1
  • Thanks, this one works!
    – Borj
    Jan 22 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.