I'm trying to create a JSON file in PS that contains some values that i have stored in some arrays.
$array = [PSCustomObject]@{
EnvironmentVariables = @()
ConnectionReferences = @(
foreach($i in $connectors){
[PSCustomObject]@{
LogicalName = $LogicalName
ConnectionId = $connectors.ConnectorName
ConnectorId = $ConnectorId
}
}
)
} | ConvertTo-Json -Depth 3
that returns the whole array for each variable. If i put [0] it takes the first value in the array and prints it. But i want it to continue to create objects for each value in these arrays. And if it's possible i would like to match some values. For example, "If $connectorId contains value from $connectors.ConnectionName" i want that to be a custom object.
This may be an easy fix, but i'm quite new to Powershell...