title: Condensing Powershell Nested If/ElseIf
body: <p>I've got a bit of a query on condensing some code. Using it in a function or two I am writing. First up some examples.</p>
  
  <p>This is the If/ElseIf method.</p>
  
  <pre><code>If ($aVar -eq 1) {
      If ($bVar -le $cVar) {
          # code
          # code
          # code
          # code
      }
  }
  ElseIf ($aVar -eq 2) {
      If ($bVar -gt $cVar) {
          # code
          # code
          # code
          # code
      }
  }
  </code></pre>
  
  <p>And here's the Switch method.</p>
  
  <pre><code>Switch ($aVar) {
      {$_ -eq 1} { 
          If ($bVar -le $cVar) {
              #code 
              #code 
              #code 
              #code 
          }
      }
      {$_ -eq 2} { 
          If ($bVar -gt $cVar) {
              #code 
              #code 
              #code 
              #code 
          }
      }
  </code></pre>
  
  <p>Is it possible to condense this at all?</p>
  
  <p>The #code sections are the exact same, so was wondering if there'd be a way of only writing it once instead of having it twice in either method used.</p>
  
  <p>Thanks!</p>