title: PowerShell 5 AppSettings Bug?
body: <p>I upgraded to PowerShell v5.0.10586.117 and now I am unable to access the AppSettings from my app.config file. The code works with PowerShell v4 (I've tried it on other computers that have v4 installed and it returns the data from AppSettings).</p>
  
  <p>I set the App Config in PowerShell
  </p>
  
  <pre><code>[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $AppConfigPath)
  </code></pre>
  
  <p>I can verify that the Current Domain has the App Settings with 
  </p>
  
  <pre><code>[System.AppDomain]::CurrentDomain.GetData("APP_CONFIG_FILE")
  </code></pre>
  
  <p>returns <code>PATH\App.config</code>
  but when I run
  </p>
  
  <pre><code>[System.Configuration.ConfigurationManager]::AppSettings.count
  </code></pre>
  
  <p>PowerShell v5 returns: <code>0</code></p>
  
  <p>but on PowerShell v4 (Windows 7, Windows Server 2008 R2 Enterprise, etc) returns: <code>5</code></p>
  
  <p>Why would the behavior be different on PowerShell 5  vs PowerShell 4? Is this a bug? Any idea how to resolve the App Settings issue?</p>
  
  <p>[More Info]</p>
  
  <p>I have tried doing a work-around with
  </p>
  
  <pre><code>      $configFile = System.Configuration.ConfigurationManager]::OpenExeConfiguration([System.Configuration.ConfigurationUserLevel]::None)
        $settings = $configFile.AppSettings.Settings
        $retVal = $settings[$keyName].Value
        $configFile.Save([System.Configuration.ConfigurationSaveMode]::Modified)
        [System.Configuration.ConfigurationManager]::RefreshSection($configFile.AppSettings.SectionInformation.Name)
  </code></pre>
  
  <p>With this work -round using the $retVal, I can get the data out of the AppSettings that I expect, but it fails later on a .dll that I'm importing that expects the App Config data to exist.</p>
  
  <p>[Update 1]:
  I upgraded to PowerShell 5 on Windows 8, Windows 8.1, and Server 2012 and got the same issue. Updated the Title and issue description to reflect that it is on all PowerShell 5 instances that I've tested.</p>
  
  <p>[Update 2]:</p>
  
  <p>Per @PetSerAl, I discovered that I will have the same issue in PowerShell v4 if I try to get the AppSetting before I set the config file
  </p>
  
  <pre><code>[System.Configuration.ConfigurationManager]::AppSettings
  [System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $AppConfigPath)
  [System.Configuration.ConfigurationManager]::AppSettings.Count
  </code></pre>
  
  <p>returns <code>0</code> in PowerShell v4.</p>
  
  <p>If I move my app config file to <code>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.config</code> then I do not have an issue returning the data, nor do I have an issue with the external dlls that I'm loading that expect information in the app config</p>