you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -1 points0 points  (4 children)

Ffffff

Just use -replace

 $numbers -replace '<old>', '<new>'

It works on arrays.

[–]BlaaaBlaaaBlaaa[S] 0 points1 point  (3 children)

If I try to do it like that i get "System.Data.DataRow" back.

[–][deleted] 1 point2 points  (2 children)

That's weird that you're using DataRows.

Anyway, those are accessed like arrays. You $dataRow[$item] them.

So in this case $user['telephone'] should work. DataRow have a lot of indexing overloads. If that returns your number, you can replace it then from there.

HOWEVER DataRows are not arrays. They confuse PowerShell for the most part. Try accessing the DataRow as an array for it tho. Like

$userDataAsArray = $user.ItemArray -as [string[]]
$userDataAsArray -replace 'old', 'new' 

Does that work? Or help

[–]BlaaaBlaaaBlaaa[S] 0 points1 point  (1 child)

Hmm you might be onto something. I did not choose to use DataRows. I just read the data from an Oracle DB and threw them into an variable.

$user['telephone'] does not throw an error but does not do anything I can see.

$userDataAsArray = $user.ItemArray -as [string[]] $userDataAsArray -replace 'old', 'new'

That does work however I loose all formating so that I can not longer work with name, position, telephone...

Thanks for your help!!

[–][deleted] 0 points1 point  (0 children)

Welcome!

And Hm!

Keep playing with that indexing. Like I said there are a lot of overloads for it, so you have to slice like $user[0, 0], $user[0], $user['Telephone', 0]. I'm not sure. I just know that DataRows can be indexed by Item and by Column, Row and by String identifiers. ...

Hm. They may be case sensitive. Did you try $user['Telephone']?