1

This is probably a very simple question but I am new to powershell arrays.

I have a multidimensional array in powershell which is populated from a CSV file. eg:

$data = Import-CSV \\filelocation\file.csv
$data

company       emailaddress
-------       ------------
company1      emailaddress1
company2      emailaddress2

I can view a specific value in the array with the following:

write-host $data.emailaddress{1]

which will output: "company2".

I want to be able to replace a string in the array but if I use the following:

$data.emailaddress[1] = "NEWemailaddress"

and

write-host $data.emailaddress{1] 

then the data is still the same.

How do I get the value to overwrite?

Thanks

1 Answer 1

2

I think what you have is an array of objects not a multi dimensional array. Try this:

$data[1].emailaddress = "NEWemailaddress"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.