### Install powershell-yaml Module Source: https://github.com/cloudbase/powershell-yaml/blob/master/README.md Installs the powershell-yaml module from the PowerShell Gallery. This is the initial step to use the module's functionalities. ```powershell Install-Module powershell-yaml ``` -------------------------------- ### Running PowerShell-YAML Unit Tests with Pester Source: https://github.com/cloudbase/powershell-yaml/blob/master/README.md Provides instructions on how to set up and run the unit tests for the powershell-yaml module. It details the prerequisite of installing Pester and Assert modules, cloning the repository, and executing the tests using `Invoke-Pester`. ```powershell PS C:\> Install-Module Pester PS C:\> Install-Module Assert PS C:\> git clone https://github.com/cloudbase/powershell-yaml.git $HOME\powershell-yaml PS C:\> cd $HOME\powershell-yaml PS C:\Users\Guest\powershell-yaml> powershell.exe -NonInteractive -Command {Invoke-Pester} ``` -------------------------------- ### Get YAML Property Comment in PowerShell Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Retrieves the comment associated with a YAML property. This function is useful for accessing comments preserved during YAML parsing or set using `Set-YamlPropertyComment`. It takes the input object and the property name as parameters. ```powershell Import-Module powershell-yaml $yaml = @" # Server hostname server: localhost # Port number port: 8080 "@ $config = ConvertFrom-Yaml $yaml -As ([PSCustomObject]) $serverComment = Get-YamlPropertyComment -InputObject $config -PropertyName 'server' # Returns: "Server hostname" $portComment = Get-YamlPropertyComment -InputObject $config -PropertyName 'port' # Returns: "Port number" ``` -------------------------------- ### YAML Merge Keys Support (Anchors and Aliases) Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Parses YAML documents that utilize anchors (&) and aliases (*) with merge keys (<<) for effective configuration inheritance and reuse. This allows defining default settings that can be extended. ```powershell Import-Module powershell-yaml $mergingYaml = @" --- default: &default value1: 1 value2: 2 hoge: <<: *default value3: 3 "@ $config = ConvertFrom-Yaml -Yaml $mergingYaml -UseMergingParser # $config.default = @{value1=1; value2=2} # $config.hoge = @{value1=1; value2=2; value3=3} # Merged from default ``` -------------------------------- ### Controlling YAML Output Formatting with PowerShell-YAML Source: https://github.com/cloudbase/powershell-yaml/blob/master/README.md Explains how to control the output style of YAML generated by `ConvertTo-Yaml` using the `-Options` parameter. It covers `UseFlowStyle` for compact output and `UseSequenceFlowStyle` for sequences in flow style. ```powershell Import-Module powershell-yaml PS C:\> $data = @{ "anArray" = @(1, 2, 3) "nested" = @{ "array" = @("this", "is", "an", "array") } "hello" = "world" } PS C:\> ConvertTo-Yaml $data -Options UseFlowStyle {anArray: [1, 2, 3], nested: {array: [this, is, an, array]}, hello: world} ``` ```powershell PS C:\> ConvertTo-Yaml $data -Options UseSequenceFlowStyle anArray: [1, 2, 3] nested: array: [this, is, an, array] hello: world ``` -------------------------------- ### Define Typed Configuration Classes and Deserialize YAML in PowerShell Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Demonstrates defining custom PowerShell classes that inherit from YamlBase for typed YAML deserialization. It shows how hyphenated keys in YAML are automatically converted to PascalCase properties in PowerShell and how to access and modify these typed objects. ```powershell class DatabaseConfig : YamlBase { [string]$Host = 'localhost' [int]$Port = 5432 [string]$Database = '' [string]$Username = '' [bool]$UseSsl = $true } class AppConfig : YamlBase { [string]$AppName = '' [string]$Version = '' [string]$Environment = 'development' [DatabaseConfig]$Database = $null [int]$MaxConnections = 100 [string[]]$AllowedOrigins = @() } $yaml = @" app-name: MyAwesomeApp version: 2.0.0 environment: production database: host: db.example.com port: 5432 database: myapp_prod username: app_user use-ssl: true max-connections: 200 allowed-origins: - https://app.example.com - https://admin.example.com "@ $config = ConvertFrom-Yaml -Yaml $yaml -As ([AppConfig]) $config.AppName $config.Database.Host $config.Database.Port $config.AllowedOrigins $config.Environment = 'staging' $config.MaxConnections = 150 $newYaml = ConvertTo-Yaml $config $newConfig = [AppConfig]::new() $newConfig.AppName = 'TestApp' $newConfig.Database = [DatabaseConfig]::new() $newConfig.Database.Host = 'localhost' $yaml = ConvertTo-Yaml $newConfig ``` -------------------------------- ### Utilize Command Aliases for YAML Conversion Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Shows the usage of convenient command aliases provided by the powershell-yaml module for frequently used commands. `cfy` is an alias for `ConvertFrom-Yaml`, and `cty` is an alias for `ConvertTo-Yaml`. These aliases simplify common YAML operations and can be used in pipeline scenarios. ```powershell Import-Module powershell-yaml # cfy = ConvertFrom-Yaml $obj = cfy "key: value" # cty = ConvertTo-Yaml $yaml = cty @{key = "value"} # Pipeline with aliases $config = Get-Content config.yaml -Raw | cfy $config.setting = "newvalue" $config | cty | Set-Content config.yaml ``` -------------------------------- ### Using Tags for Type Conversion in PowerShell-YAML Source: https://github.com/cloudbase/powershell-yaml/blob/master/README.md Demonstrates how to use YAML tags like '!!str' to explicitly define data types during YAML conversion in PowerShell. This prevents unintended type casting, such as phone numbers being converted to integers. ```powershell Import-Module powershell-yaml PS C:\> $data = @" aPhoneNumber: !!str +40123456789 aPhoneNrWithoutTags: +40123456789 "@ PS C:\> ConvertFrom-Yaml $data Name Value ---- ----- aPhoneNrWithoutTags 40123456789 aPhoneNumber +40123456789 PS C:\> $obj = ConvertFrom-Yaml $data PS C:\> $obj.aPhoneNumber.GetType() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True String System.Object PS C:\> $obj.aPhoneNrWithoutTags.GetType() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Int64 System.ValueType ``` -------------------------------- ### Preserve YAML Metadata with PSCustomObject Mode in PowerShell Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Demonstrates using `ConvertFrom-Yaml -As ([PSCustomObject])` to parse YAML while preserving metadata such as comments, tags, and scalar styles. This enables round-trip editing of YAML files, ensuring that original formatting and comments are maintained. ```powershell Import-Module powershell-yaml $yaml = @" # Application configuration app-name: "MyApp" version: '1.0.0' environment: production # Database settings database: host: db.example.com port: !!int 5432 "@ $config = ConvertFrom-Yaml $yaml -As ([PSCustomObject]) $config.'app-name' $config.database.host if (Test-YamlMetadata $config) { $comment = Get-YamlPropertyComment -InputObject $config -PropertyName 'app-name' } $config.environment = 'staging' $newYaml = ConvertTo-Yaml $config ``` -------------------------------- ### Map Custom YAML Keys to PowerShell Properties with YamlKey Attribute Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Illustrates using the `[YamlKey]` attribute in PowerShell to map YAML keys (especially case-sensitive ones) to PowerShell properties with different names. This is crucial when YAML keys do not follow PowerShell's PascalCase convention or when explicit case sensitivity is required during deserialization and serialization. ```powershell Import-Module powershell-yaml class ServerEndpoint : YamlBase { [YamlKey("HTTP")] [string]$HttpUrl = "" [YamlKey("HTTPS")] [string]$HttpsUrl = "" [int]$Port = 0 } class ServerConfig : YamlBase { [YamlKey("Host")] [string]$PrimaryHost = "" [YamlKey("host")] [string]$BackupHost = "" [int]$Port = 8080 } $yaml = @" Host: primary.example.com host: backup.example.com port: 8080 "@ $config = ConvertFrom-Yaml $yaml -As ([ServerConfig]) $config.PrimaryHost $config.BackupHost $newYaml = ConvertTo-Yaml $config ``` -------------------------------- ### Detect Duplicate YAML Keys in PowerShell Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Explains how the powershell-yaml module detects duplicate keys in YAML input to prevent data loss. It shows how duplicate keys are handled differently in PSCustomObject mode (error) versus typed mode with explicit mappings (allows case-sensitive mapping). ```powershell Import-Module powershell-yaml $yaml = @" test: hello Test: world "@ try { $obj = ConvertFrom-Yaml $yaml -As ([PSCustomObject]) } catch { Write-Host "Error: Duplicate keys detected" } class ConfigWithMapping : YamlBase { [YamlKey("test")] [string]$LowercaseValue = "" [YamlKey("Test")] [string]$CapitalizedValue = "" } $config = ConvertFrom-Yaml $yaml -As ([ConfigWithMapping]) $config.LowercaseValue $config.CapitalizedValue ``` -------------------------------- ### Control YAML Serialization Behavior with SerializationOptions Flags Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Demonstrates how to control YAML serialization behavior using the `SerializationOptions` enum flags in PowerShell. Multiple options can be combined using the bitwise OR operator (`-bor`). Available options include controlling round-trip mode, alias generation, default value emission, JSON compatibility, type resolution, indentation, and null value handling. ```powershell Import-Module powershell-yaml $data = @{ name = "Test" items = @(1, 2, 3) config = @{ enabled = $true } } # Available options: # - None: Default serialization # - Roundtrip: Enable round-trip mode # - DisableAliases: Prevent YAML anchor/alias generation # - EmitDefaults: Include default values # - JsonCompatible: JSON-compatible output # - DefaultToStaticType: Use static type resolution # - WithIndentedSequences: Indent array items # - OmitNullValues: Skip null properties # - UseFlowStyle: Flow style for all (inline) # - UseSequenceFlowStyle: Flow style for arrays only # - UseBlockStyle: Block style for all (multi-line) # - UseSequenceBlockStyle: Block style for arrays only # Combine multiple options $options = [SerializationOptions]::WithIndentedSequences -bor [SerializationOptions]::DisableAliases $yaml = ConvertTo-Yaml $data -Options $options # JSON-compatible with omit nulls $jsonOpts = [SerializationOptions]::JsonCompatible -bor [SerializationOptions]::OmitNullValues $json = ConvertTo-Yaml $data -Options $jsonOpts ``` -------------------------------- ### Indenting Sequences in PowerShell-YAML Output Source: https://github.com/cloudbase/powershell-yaml/blob/master/README.md Illustrates how to control indentation of sequences in YAML output using the `WithIndentedSequences` option with `ConvertTo-Yaml`. This option affects how list items are displayed in the generated YAML. ```powershell PS C:\> ConvertTo-Yaml $data anArray: - 1 - 2 - 3 nested: array: - this - is - an - array hello: world PS C:\> ConvertTo-Yaml $data -Options WithIndentedSequences anArray: - 1 - 2 - 3 nested: array: - this - is - an - array hello: world ``` -------------------------------- ### Convert YAML with Merge Keys to PowerShell Object Source: https://github.com/cloudbase/powershell-yaml/blob/master/README.md Deserializes YAML content that utilizes merge keys ('<<') to combine default values into a specific section. The '-UseMergingParser' switch must be enabled. This function processes YAML with inheritance-like structures. ```powershell $mergingYaml = @" --- default: &default value1: 1 value2: 2 hoge: <<: *default value3: 3 "@ ConvertFrom-Yaml -Yaml $mergingYaml -UseMergingParser ``` -------------------------------- ### YamlBase Metadata Methods in PowerShell Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Provides direct access to metadata management methods (comments, tags, styles) on objects inheriting from `YamlBase`. These methods allow programmatic manipulation of YAML-specific attributes for properties within the object. ```powershell Import-Module powershell-yaml class AppConfig : YamlBase { [string]$ServiceName = "" [string]$ApiVersion = "" [int]$MaxRetries = 3 } $yaml = @" # Service configuration service-name: ApiGateway api-version: v2.1 max-retry-count: !!int 5 "@ $config = ConvertFrom-Yaml $yaml -As ([AppConfig]) # Get preserved metadata $comment = $config.GetPropertyComment('ServiceName') # "Service configuration" $tag = $config.GetPropertyTag('MaxRetries') # "tag:yaml.org,2002:int" # Set metadata programmatically $config.SetPropertyComment('ApiVersion', 'API version identifier') $config.SetPropertyTag('MaxRetries', 'tag:yaml.org,2002:int') $config.SetPropertyScalarStyle('ServiceName', 'SingleQuoted') $newYaml = ConvertTo-Yaml $config ``` -------------------------------- ### Convert PowerShell Object to YAML Source: https://github.com/cloudbase/powershell-yaml/blob/master/README.md Serializes a PowerShell object into a YAML formatted string. It requires the module to be imported first. The output is a YAML string representing the input object. ```powershell Import-Module powershell-yaml PS C:\> $yaml = ConvertTo-Yaml @{"hello"="world"; "anArray"=@(1,2,3); "nested"=@{"array"=@("this", "is", "an", "array")}} ``` -------------------------------- ### Convert YAML to PowerShell Objects (ConvertFrom-Yaml) Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Converts YAML string content into PowerShell objects. This function supports single and multiple YAML documents, ordered dictionaries, and merge keys (anchors/aliases). It also offers optional type-safe deserialization to custom classes. ```powershell Import-Module powershell-yaml # Basic YAML to hashtable conversion $yaml = @" anArray: - 1 - 2 - 3 nested: array: - this - is - an - array hello: world "@ $obj = ConvertFrom-Yaml $yaml # $obj is a hashtable # $obj.hello = "world" # $obj.anArray = @(1, 2, 3) # $obj.nested.array = @("this", "is", "an", "array") # Ordered dictionary (preserves key order) $ordered = ConvertFrom-Yaml $yaml -Ordered # Multiple YAML documents $multiDoc = @" --- name: first value: 1 --- name: second value: 2 "@ $docs = ConvertFrom-Yaml $multiDoc -AllDocuments # $docs[0].name = "first" # $docs[1].name = "second" # Pipeline support $result = Get-Content "./config.yaml" -Raw | ConvertFrom-Yaml ``` -------------------------------- ### Type-Safe Deserialization with YamlBase Classes Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Enables type-safe YAML deserialization by defining PowerShell classes that inherit from the `YamlBase` class. This facilitates automatic property name conversion, handling of nested objects, and preservation of metadata for round-trip editing. ```powershell Import-Module powershell-yaml # Example of defining a class inheriting from YamlBase # class MyObject : YamlBase { # [string]$Name # [int]$Id # [MyNestedObject]$Details # } # class MyNestedObject : YamlBase { # [string]$Description # } # $yamlContent = @" # Name: Example Item # Id: 123 # Details: # Description: This is a nested object. # "@ # $deserializedObject = ConvertFrom-Yaml $yamlContent -Type MyObject ``` -------------------------------- ### Convert PowerShell Objects to YAML (ConvertTo-Yaml) Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Converts PowerShell objects (hashtables, arrays, PSCustomObjects) into YAML string format. It supports various output formatting options such as flow style, block style, indented sequences, and JSON-compatible output. The command can also write directly to a file. ```powershell Import-Module powershell-yaml # Basic conversion from hashtable to YAML $data = @{ "hello" = "world" "anArray" = @(1, 2, 3) "nested" = @{ "array" = @("this", "is", "an", "array") } } $yaml = ConvertTo-Yaml $data # Output: # anArray: # - 1 # - 2 # - 3 # nested: # array: # - this # - is # - an # - array # hello: world # JSON-compatible output (single line) $json = ConvertTo-Yaml $data -JsonCompatible # Output: {"anArray": [1, 2, 3], "nested": {"array": ["this", "is", "an", "array"]}, "hello": "world"} # Flow style output $flowYaml = ConvertTo-Yaml $data -Options UseFlowStyle # Output: {anArray: [1, 2, 3], nested: {array: [this, is, an, array]}, hello: world} # Sequence flow style (arrays inline, mappings block) $seqFlowYaml = ConvertTo-Yaml $data -Options UseSequenceFlowStyle # Output: # anArray: [1, 2, 3] # nested: # array: [this, is, an, array] # hello: world # Indented sequences $indentedYaml = ConvertTo-Yaml $data -Options WithIndentedSequences # Output: # anArray: # - 1 # - 2 # - 3 # nested: # array: # - this # - is # - an # - array # hello: world # Write directly to file ConvertTo-Yaml $data -OutFile "./config.yaml" -Force ``` -------------------------------- ### Custom YAML Type Converters in PowerShell Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Enables handling of specialized types and YAML tags by creating custom converters that inherit from `YamlConverter`. These converters define how to serialize and deserialize specific types, allowing for custom tag handling like `!semver`. ```powershell Import-Module powershell-yaml # Custom type for semantic versioning class SemanticVersion { [int]$Major = 0 [int]$Minor = 0 [int]$Patch = 0 [string]$PreRelease = "" [string] ToString() { $ver = "$($this.Major).$($this.Minor).$($this.Patch)" if ($this.PreRelease) { $ver += "-$($this.PreRelease)" } return $ver } } # Custom converter for !semver tag class SemVerConverter : YamlConverter { [bool] CanHandle([string]$tag, [Type]$targetType) { return $tag -eq '!semver' -and $targetType -eq [SemanticVersion] } [object] ConvertFromYaml([object]$data, [string]$tag, [Type]$targetType) { $sv = [SemanticVersion]::new() if ($data -is [string]) { # Parse "1.2.3-beta1" format $parts = $data -split '-', 2 $nums = $parts[0] -split '\\.' $sv.Major = [int]$nums[0] $sv.Minor = [int]$nums[1] $sv.Patch = [int]$nums[2] if ($parts.Count -gt 1) { $sv.PreRelease = $parts[1] } } return $sv } [hashtable] ConvertToYaml([object]$value) { return @{ Value = $value.ToString(); Tag = '!semver' } } } # Class using custom converter class AppRelease : YamlBase { [string]$AppName = "" [YamlConverter("SemVerConverter")] [SemanticVersion]$Version = $null } $yaml = @" app-name: MyApp version: !semver "2.1.5-beta3" "@ $release = ConvertFrom-Yaml $yaml -As ([AppRelease]) $release.Version.Major # 2 $release.Version.Minor # 1 $release.Version.Patch # 5 $release.Version.PreRelease # "beta3" # Serialize back with tag preserved $newYaml = ConvertTo-Yaml $release ``` -------------------------------- ### Convert YAML String to PowerShell Objects (Multiple Documents) Source: https://github.com/cloudbase/powershell-yaml/blob/master/README.md Deserializes a YAML string containing multiple YAML documents into an array of PowerShell objects. The '-AllDocuments' switch is crucial for this functionality. Note that the output array does not directly translate back to the original multiple documents via ConvertTo-Yaml. ```powershell Import-Module powershell-yaml PS C:\> $yaml = @" --- anArray: - 1 - 2 - 3 nested: array: - this - is - an - array hello: world --- second: document goodbye: world "@ PS C:\> $obj = ConvertFrom-Yaml $yaml -AllDocuments ``` -------------------------------- ### Convert YAML String to PowerShell Object (Single Document) Source: https://github.com/cloudbase/powershell-yaml/blob/master/README.md Deserializes a single YAML formatted string into a PowerShell object, typically a Hashtable. The module must be imported before use. The output is a PowerShell object. ```powershell Import-Module powershell-yaml PS C:\> $yaml = @" anArray: - 1 - 2 - 3 nested: array: - this - is - an - array hello: world "@ PS C:\> $obj = ConvertFrom-Yaml $yaml ``` -------------------------------- ### Convert PowerShell Object to JSON-Compatible YAML Source: https://github.com/cloudbase/powershell-yaml/blob/master/README.md Serializes a PowerShell object into a YAML string that is compatible with JSON structure, effectively producing a compact, single-line JSON-like output. This is useful for interoperability with systems expecting JSON. Indentation is not supported. ```powershell Import-Module powershell-yaml PS C:\> $yaml = @" anArray: - 1 - 2 - 3 nested: array: - this - is - an - array hello: world "@ PS C:\> $obj = ConvertFrom-Yaml $yaml PS C:\> ConvertTo-Yaml -JsonCompatible $obj ``` -------------------------------- ### Add Comments to YAML Properties in PowerShell Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Shows how to use `Set-YamlPropertyComment` to programmatically add or update comments associated with YAML properties. This function is applicable to objects parsed using `ConvertFrom-Yaml -As [PSCustomObject]` or those inheriting from `YamlBase`, ensuring comments are preserved during serialization. ```powershell Import-Module powershell-yaml $yaml = @" server: localhost port: 8080 "@ $config = ConvertFrom-Yaml $yaml -As ([PSCustomObject]) $config | Set-YamlPropertyComment -PropertyName 'server' -Comment 'Primary server address' $config | Set-YamlPropertyComment -PropertyName 'port' -Comment 'HTTP listener port' $newYaml = ConvertTo-Yaml $config ``` -------------------------------- ### Test YAML Metadata in PowerShell Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Tests if a PSCustomObject has YAML metadata attached, indicating it was created with `ConvertFrom-Yaml -As [PSCustomObject]`. It returns `$true` if metadata is present and supported, and `$false` otherwise. This is useful for conditional operations on YAML-parsed objects. ```powershell Import-Module powershell-yaml # Object with metadata $yamlObj = ConvertFrom-Yaml "key: value" -As ([PSCustomObject]) Test-YamlMetadata $yamlObj # Returns: $true # Regular hashtable (no metadata) $hashObj = ConvertFrom-Yaml "key: value" Test-YamlMetadata $hashObj # Returns: $false # Conditional metadata operations if (Test-YamlMetadata $config) { $config | Set-YamlPropertyComment -PropertyName 'Name' -Comment 'User name' } ``` -------------------------------- ### Control Depth for Nested Objects in YAML Serialization Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Illustrates how to control the maximum recursion depth when serializing deeply nested objects to prevent stack overflows and limit output complexity. The default depth is 100, but it can be explicitly set using the `-Depth` parameter. ```powershell Import-Module powershell-yaml $deeplyNested = @{ level1 = @{ level2 = @{ level3 = @{ level4 = @{ value = "deep" } } } } } # Default depth is 100 $yaml = ConvertTo-Yaml $deeplyNested # Limit depth to prevent excessive nesting $limitedYaml = ConvertTo-Yaml $deeplyNested -Depth 3 ``` -------------------------------- ### YAML Tags for Type Safety Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Utilizes YAML tags to explicitly define data types, preventing ambiguous type inference. The module supports core schema tags like str, int, float, bool, null, and timestamp, ensuring accurate data representation. ```powershell Import-Module powershell-yaml $yaml = @" aPhoneNumber: !!str +40123456789 aPhoneNrWithoutTags: +40123456789 anInteger: !!int 42 aFloat: !!float 3.14 aTimestamp: !!timestamp 2024-01-15T10:30:00Z aNull: !!null ~ "@ $obj = ConvertFrom-Yaml $yaml # $obj.aPhoneNumber is String: "+40123456789" (preserved with + sign) # $obj.aPhoneNrWithoutTags is Int64: 40123456789 (inferred as number) # $obj.anInteger is Int32: 42 # $obj.aFloat is Decimal: 3.14 # $obj.aTimestamp is DateTime # $obj.aNull is $null ``` -------------------------------- ### Set YAML Property Scalar Style in PowerShell Source: https://context7.com/cloudbase/powershell-yaml/llms.txt Controls the formatting style of a property value when converting to YAML. It supports Plain, SingleQuoted, DoubleQuoted, Literal (|), and Folded (>) styles. This function is applied to a configuration object and specifies the property name and desired style. ```powershell Import-Module powershell-yaml $yaml = @" name: MyApp description: A simple description "@ $config = ConvertFrom-Yaml $yaml -As ([PSCustomObject]) # Set different scalar styles $config | Set-YamlPropertyScalarStyle -PropertyName 'name' -Style SingleQuoted $config | Set-YamlPropertyScalarStyle -PropertyName 'description' -Style Literal $newYaml = ConvertTo-Yaml $config # Output: # name: 'MyApp' # description: | # A simple description ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.