SOLVED

Escaping the content of a Rich Text Field

%3CLINGO-SUB%20id%3D%22lingo-sub-162629%22%20slang%3D%22en-US%22%3EEscaping%20the%20content%20of%20a%20Rich%20Text%20Field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-162629%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%0A%3CP%3EI%20have%20a%20field%20which%20has%20some%20mark%20up%20in%20the%20text%26nbsp%3Beg.%20%3C%2FP%3E%3CDIV%3E%2C%20%3CSPAN%3E%20so%20I%20need%20to%20escape%20this%20markup.%26nbsp%3B%20Is%20there%20an%20easy%20way%20to%20do%20this%20in%20PnP%20PowerShell.%3CP%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERegards%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENigel%3C%2FP%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-162629%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-163611%22%20slang%3D%22en-US%22%3ERe%3A%20Escaping%20the%20content%20of%20a%20Rich%20Text%20Field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-163611%22%20slang%3D%22en-US%22%3E%3CP%3EYes%2C%20there%20is%20!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%24value%20%3D%20%5BSystem.Net.WebUtility%5D%3A%3AHtmlEncode(%24fieldValue.Value)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Regular Contributor

Hi

I have a field which has some mark up in the text eg. <div>, <span> so I need to escape this markup.  Is there an easy way to do this in PnP PowerShell.

 

Regards

 

Nigel

1 Reply
Best Response confirmed by Nigel Price (Regular Contributor)
Solution

Yes, there is !

 

$value = [System.Net.WebUtility]::HtmlEncode($fieldValue.Value)