{"id":7022,"date":"2015-04-20T09:21:00","date_gmt":"2015-04-20T09:21:00","guid":{"rendered":""},"modified":"2026-04-18T22:36:13","modified_gmt":"2026-04-18T22:36:13","slug":"powershell-loop-all-regex-matches","status":"publish","type":"post","link":"https:\/\/hellem.org\/wblog\/?p=7022","title":{"rendered":"Powershell &#8211; Loop all regex matches"},"content":{"rendered":"<p>Using log4net in this example to write output, replace with Write-Host etc if needed. Piping to Out-String being the magic here, or else you just get the object class<\/p>\n<p><!-- codeblock lang= line=1 --><\/p>\n<pre class=\"codeblock\"><code>\r\n\r\n foreach ($m in $matches.GetEnumerator()) {\r\n    $log.debugFormat(\"Matches are {0}\", ($m | Out-String))\r\n }\r\n\t\t\t\r\n<\/code><\/pre>\n<p><!-- \/codeblock --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using log4net in this example to write output, replace with Write-Host etc if needed. Piping to Out-String being the magic here, or else you just get the object class foreach ($m in $matches.GetEnumerator()) { $log.debugFormat(&#8220;Matches are {0}&#8221;, ($m | Out-String)) }<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[],"class_list":["post-7022","post","type-post","status-publish","format-standard","hentry","category-work-geek"],"_links":{"self":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/7022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7022"}],"version-history":[{"count":1,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/7022\/revisions"}],"predecessor-version":[{"id":10571,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/7022\/revisions\/10571"}],"wp:attachment":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}