1

I'm trying to filter a large list to pull out any values that have trailing or leading spaces using a powershell script. I can do it using a where-object command ($items| ? {$_["field"].StartsWith(' ')}), but it's really inefficient and will take a really long time to run. I'm looking to see if there's a way to accomplish this using an spQuery (i.e. CAML). I've tried using CAML with a space in the value but it returns no items.

             <Contains>
                <FieldRef Name='Location' />
                <Value Type='Text'> </Value>
             </Contains>

Using <BeginsWith> comes up with a similarly null result.

Is there a faster way to do this or am I stuck iterating?

1 Answer 1

0

I figured out a work around for my issue. Basically, I made a calculated column to find leading or trailing spaces and built my CAML on that. Here's the formula =IF(OR(CODE(LEFT(MYFIELD,1))=32,CODE(RIGHT(MYFIELD,1))=32),"Space","No Space")

Your Answer

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

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