title: error defining array in a script, it works if typed out however
body: <p>I'm trying to create an audio toggle. I've written it before but new OS and dll updates forced me to rewrite it, the method i used previously doesn't seem to work any longer.
  So right out of the gate my first line spits out this error:</p>
  
  <pre><code>$audio : The term '$audio' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that 
  the path is correct and try again.
  At D:\audiochanger.ps1:1 char:1
  + $audio = Get-AudioDevice -playback
  + ~~~~~~~
      + CategoryInfo          : ObjectNotFound: ($audio:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
  </code></pre>
  
  <p>but if i type in <code>$audio = Get-AudioDevice -playback</code> and then call <code>$audio</code>, it works perfectly fine. Whats going on?</p>
  
  <pre><code>$audio = Get-AudioDevice -playback
  $audio.Name
  if ($audio.Name -eq 'Speakers (Realtek High Definition Audio)') {
  set-audiodevice 1 
  }  Else {
  set-audiodevice 2
  }
  </code></pre>
  
  <p>output of <code>Get-AudioDevice -playback</code></p>
  
  <pre><code>
  Index   : 2
  Default : True
  Type    : Playback
  Name    : Speakers (Realtek High Definition Audio)
  ID      : {0.0.0.00000000}.{2aa2a27b-4ebc-4355-bdf7-093a8f97ba46}
  Device  : CoreAudioApi.MMDevice
  
  or
  
  Index   : 1
  Default : True
  Type    : Playback
  Name    : Speakers (Logitech G533 Gaming Headset)
  ID      : {0.0.0.00000000}.{1f5d6b65-fe9b-4bda-9508-d1a204149395}
  Device  : CoreAudioApi.MMDevice
  </code></pre>
  
  <p>this is running on windows 10 and powershell 5. my previous working code can be found here: <a href="https://stackoverflow.com/questions/47361611/need-to-select-an-item-based-on-the-name-in-an-array-using-powershell">need to select an item based on the name in an array using powershell</a></p>