-
Notifications
You must be signed in to change notification settings - Fork 80
Closed
Description
Steps to reproduce
$CustomObject = [pscustomobject]@{firstname="John"; url=$null; comment="foo bar"}
ConvertTo-Yaml $CustomObjectOutcome
Convert-PSObjectToGenericObject : Cannot bind argument to parameter 'Data' because it is null.
Workaround
I'm currently using a modified version of Convert-PSCustomObjectToDictionary to accommodate members with a value of $null:
function Convert-PSCustomObjectToDictionary {
Param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[PSCustomObject]$Data
)
$ret = [System.Collections.Generic.Dictionary[string,object]](New-Object 'System.Collections.Generic.Dictionary[string,object]')
foreach ($i in $Data.psobject.properties) {
If ($i.Value) {
$ret[$i.Name] = Convert-PSObjectToGenericObject $i.Value
}
Else {
$ret[$i.Name] = ""
}
}
return $ret
}Environment details
- powershell-yaml version: 0.3.1
- PowerShell version:
$psversiontable
Name Value
---- -----
PSVersion 5.1.16299.98
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.98
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels