How to initialize / define an array of arrays

I would like to have an array of arrays with, for a start, two string variables.

How can I define this or build it via eg. looping?

$OrgUnit_A = [pscustomobject]@{ServerName=‘server_1’;FileName=‘Fil_1’},
[pscustomobject]@{ServerName=‘server_2’;FileName=‘Fil_2’}

The OrgUnit will have eg. 100 objects where each object consists og a servername and a filename.

How can this be initialized, objects be added and referenced?

Hi,
This should be helpful

Thanks for your answer. Still I haven’t found a working solution for my problem.
I think I simply haven’t seen the light yet.

I would like to have an array consisting of eg 100 lines, where each line consists of two values.

It would be fine to initialize from the start and afterwards fill in the correct data.

$b =@([pscustomobject]@{servername=‘’;Filename=‘’})

$b could represent one line.

The values can be referenced / changed as shown below.

$b[0].servername = ‘Server_1’
$b[0].filename = ‘Fil_nr_1’

I would like to define a variable with 100 of these lines.

Could you point me in the right direction? Thank a lot

There’s no need to initialize empty arrays in PowerShell. What do you like to do actually?

Like this ?

$Servers = @(
            [pscustomobject]@{ServerName=‘server_1’;FileName=‘Fil_1’},
            [pscustomobject]@{ServerName=‘server_2’;FileName=‘Fil_2’}
            )

Output:

image