You can achieve it using RegEx as well - First, you need to get the item, and then from the item, you need to get the field value. here below example will work fine for a single item but if you need it for multiple items you need to perform a loop, for example, getting children of a root item.
$anchorTagPattern = '(?is)<a[^>]*>(.*?)<\/a>';
$hrefPattern = '(?is)href=\"[^>]*(.*?)\"';
#You can get Html
#get contentitem fromby item field
#$htmlContent =id $itemi.Fields["Your Rich Text Contente Field"].Value;{BB87FEE6-E4CF-4D86-986B-2D1B297A081F}
$htmlContent$item = @"
<div class="test">
Get-Item -Path "master:" <div-ID class="test">"{BB87FEE6-E4CF-4D86-986B-2D1B297A081F}"
<blockquote>hello<br />
#get field <spanvalue class="test">hello</span>
by field name i.e </blockquote>Content
$htmlContent <a= href="test$item.com">test</a>
</div>
</div>Fields["Content"].Value;
"@;
$anchorTagPatternMatches = [regex]::Matches($htmlContent,
$anchorTagPattern);
if(![string]::IsNullOrEmpty($anchorTagPatternMatches)) {
write-host
$anchorTagPatternMatches | ForEach-Object {
$anchorText = $anchorTagPatternMatches[0]$_.Groups[1].Value;
$anchorTag = $anchorTagPatternMatches[0]$_[0].Value;
write-host $anchorTag
write-host $anchorText
if(![string]::IsNullOrEmpty($anchorTag)){
$hrefPatternMatches = [regex]::Matches($anchorTag, $hrefPattern);
$href = $hrefPatternMatches[0].Value;
$href = $href.Replace('href=','');
write-host $href
}
}
}