convertfrom-yaml does not preserve single-element arrays.
Example:
# Create a hash with two key-value pairs. Both values are arrays, but one of them
# has just a single element
$j = [ordered]@{
apac = @('Australia')
emea = @('Italy', 'Finland')
}
#Confirm that both values are arrays
PS C:\> $j.apac.gettype().name
Object[]
PS C:\> $j.emea.gettype().name
Object[]
# Convert to yaml. Good so far, we still have two arrays/sequences.
PS C:\> $j | convertto-yaml
---
apac:
- 'Australia'
emea:
- 'Italy'
- 'Finland'
# Convert back to a PowerShell object and we lose one of the arrays.
# Now we have one array and one scalar. We should have two arrays.
PS C:\> $j = $j | convertto-yaml | convertfrom-yaml
PS C:\> $j.apac.gettype().name
String
PS C:\> $j.emea.gettype().name
Object[]
convertfrom-yaml does not preserve single-element arrays.
Example: