'Concatenate two properties inline in select-object
I have an object array like
{
Id: 1,
Name: Name1,
Users:
[
{
Identifier: [email protected],
AccessRight: Admin
},
{
Identifier: [email protected],
AccessRight: Member
}
]
},
{
Id: 2,
Name: Name2,
Users:
[
{
Identifier: [email protected],
AccessRight: Admin
}
]
}
I want to produce the following csv output
| Id | Name | Users |
|---|---|---|
| 1 | Name1 | [email protected];Admin,[email protected];Member |
| 2 | Name2 | [email protected];Admin |
I'm failing on concatenating the Users...
$users | Select Id, Name, @{Name="Users";Expression={ $_.Users.Identifier -join "," }}
produces:
| Id | Name | Users |
|---|---|---|
| 1 | Name1 | [email protected],[email protected] |
| 2 | Name2 | [email protected] |
How can I concatenate the Identifier + AccessRight with semicolon part before joining with commas?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
