3
This powershell module is a thin wrapper on top of [YamlDotNet](https://github.com/aaubry/YamlDotNet "YamlDotNet") that serializes and un-serializes simple powershell objects to and from YAML. It was tested on powershell versions 4 and 5 and supports [Nano Server](https://technet.microsoft.com/en-us/library/mt126167.aspx Nano).
5
The ```lib``` folder contains the YamlDotNet assemblies. They are not really required, just a fall-back in case your system does not already have them installed and loaded. Feel free to remove the ```lib``` folder if you prefer to add the required assemblies yourself.
10
Import-Module powershell-yaml
12
PS C:\> $yaml = ConvertTo-Yaml @{"hello"="world"; "anArray"=@(1,2,3); "nested"=@{"array"=@("this", "is", "an", "array")}}
29
### Single YAML document
32
Import-Module powershell-yaml
48
PS C:\> $obj = ConvertFrom-Yaml $yaml
57
PS C:\> $obj.GetType()
59
IsPublic IsSerial Name BaseType
60
-------- -------- ---- --------
61
True True Hashtable System.Object
64
### Multiple YAML documents
66
Unserializing multiple documents results in an array representing the contents of each document. The result of this does not translate back to the same documents if you pass it back through ConvertTo-Yaml.
69
Import-Module powershell-yaml
89
PS C:\> $obj = ConvertFrom-Yaml $yaml -AllDocuments
100
PS C:\> $obj.GetType()
102
IsPublic IsSerial Name BaseType
103
-------- -------- ---- --------
104
True True Object[] System.Array
122
## Running the tests.
124
Before running the associated unit tests; please make sure you have
125
[Pester](https://github.com/pester/pester) installed, as it is the testing
128
After Pester is up and running, the tests may be ran by simply entering the
129
tests directory and running `Invoke-Pester`:
132
PS C:\> git clone https://github.com/cloudbase/powershell-yaml.git $HOME\powershell-yaml
133
PS C:\> cd $HOME\powershell-yaml
134
PS C:\Users\Guest\powershell-yaml> powershell.exe -NonInteractive -Command {Invoke-Pester}