title: Parse YAML file in Powershell
body: <p>I want to parse an YAML file from IBM API Connect in a PowerShell file. I won't be able to put third party packages or DLLs since security review won't agree with it.</p>
  
  <pre class="lang-yaml prettyprint-override"><code>---
  product: "1.0.0"
  info:
    name: "api2product"
    title: "API2product"
    version: "1.0.0"
  visibility:
    view:
      enabled: true
      type: "public"
      tags: []
      orgs: []
    subscribe:
      enabled: true
      type: "authenticated"
      tags: []
      orgs: []
  apis:
    api1:
      $ref: "api1_1.0.0.yaml"
    api2:
      $ref: "api2_1.0.0.yaml"
    api3:
      $ref: "api3_1.0.0.yaml"
    api4:
      $ref: "api4_1.0.0.yaml"
    api5:
      $ref: "api5_1.0.0.yaml"
  plans:
    default:
      title: "Default Plan"
      description: "Default Plan"
      approval: false
      rate-limit:
        hard-limit: false
        value: "100/hour"
  </code></pre>
  
  <p>I am interested to get only the API YAML files associated with it for which I have googled and developed a sample PowerShell code which is actually running.</p>
  
  <pre class="lang-cs prettyprint-override"><code>$text = Get-Content -Path "C:\Users\abhi\Desktop\projects\TRYG\GitLab\APIPOC\test.yaml"
  $regex = '(?ms)apis:(.+?)plans:'
  $text = $text -join "`n"
  $OutputText = [regex]::Matches($text, $regex) |
                foreach {$_.Groups[1].Value -split $regex}
  $OutputText = $OutputText.Replace("`$ref:", "")
  $OutputText = $OutputText.Replace(":", "=")
  $OutputText = $OutputText.Replace("=`n", "=")
  $OutputText = $OutputText.Replace("`"", "")
  $AppProps = ConvertFrom-StringData ($OutputText)
  $AppProps.GetEnumerator() | ForEach-Object {$_.Value}
  [string[]]$l_array = $AppProps.Values | Out-String -Stream
  </code></pre>
  
  <p>Is there any simple way to achieve this instead of multiple replacements in the string?</p>