0

I'm working on a PSE script that will work on different sitecore environment with different sitecore versions. This script basically get the list of items that is recently updated between to given dates.

$fromdate = New-Object DateTime 2020, 8, 1, 0, 0, 0, ([DateTimeKind]::Utc)
$todate = New-Object DateTime 2020, 12, 1, 0, 0, 0, ([DateTimeKind]::Utc)

$criteria = @(
    @{Filter = "GreaterThan"; Field = "__smallupdateddate"; Value = $fromdate}
    @{Filter = "LessThan"; Field = "__smallupdateddate"; Value = $todate} 
)
#return list code goes here

However in one of the environments with SPE 3.0 installed that script is not working. anyone could help me how to do this that is compatible with lower versions of SPE? This is the error I am getting:

Find-Item : Cannot bind parameter 'Criteria'. Cannot create object of type "Cognifide.PowerShell.Commandlets.Data.Search.SearchCriteria". Cannot convert value "GreaterThan" to type "Cognifide.PowerShell.Commandlets.Data.Search.FilterType". Error: "Unable to match the identifier name GreaterThan to a valid enumerator name. Specify one of the following enumerator names and try again: None, Equals, StartsWith, Contains, ContainsAll, ContainsAny, EndsWith, DescendantOf, Fuzzy, InclusiveRange, ExclusiveRange, MatchesRegex, MatchesWildcard"

Thanks, Borj

2
  • 1
    SPE 3.0!? It's January 2021 and SPE 6.2 is released. Commented Jan 25, 2021 at 15:15
  • There are old websites that is still using it.
    – Borj
    Commented Jan 27, 2021 at 10:30

1 Answer 1

1

Sitecore Powershell Extensions 3.0 contains only next filter types:

None,
Equals,
StartsWith,
Contains,
EndsWith

Please upgrade PowerShell to the latest version. You will get bigger list of filters:

None,
Equals,
StartsWith,
Contains,
ContainsAll,
ContainsAny,
EndsWith,
DescendantOf,
Fuzzy,
InclusiveRange,
ExclusiveRange,
MatchesRegex,
MatchesWildcard,
GreaterThan,
LessThan

And as there is GreaterThan and LessThan - your code will start to work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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