I have a dataTable created and filled in PowerShell from a SQL query.
I need to loop through each datatable row, find a match on (space/space) and replace that with just (/) (per a customer's request)
I need to replace that match for every row.
I've done countless searches and have tried the following:
$dt | where {$_.l4 -cmatch " / "} | foreach {$_.l4 = "/"}
But that replaces the entire value to just (/)
I've tried using replace, creplace and many other ForEach loops, IF statements, etc,..
This is essentially what I am trying to do:
#loop through the datatable and replace " / " with "/"
foreach ($Row in $dt.Rows) {
if($Row -cmatch " - "){
$Row -creplace " - ","/"
}
}
Please tell me I am blatantly missing something.
I appreciate your help and guidance as I further my knowledge of PowerShell!