title: C# in PowerShell: Language Mode Not Supported
body: <p>I am trying to get a very simple script to work in PowerShell, and it keep popping back with the following error:</p>
  
  <pre><code>Add-Type : Cannot add type. Definition of new types is not supported in this language mode.
  At C:\Users\jdkin_000.ATHENA\cs_init.ps1:16 char:1
  + Add-Type -TypeDefinition $Source -Language CSharp
  </code></pre>
  
  <p>Here is the script:</p>
  
  <pre><code>$Source = @"
  using System;
  
  namespace cs1
  {
      public class Program
      {
          public static void Main()
          {
              Console.WriteLine("Hello world!");
          }
      }
  }
  "@
  
  Add-Type -TypeDefinition $Source -Language CSharp
  </code></pre>
  
  <p>Any suggestions on how to get this script to work on the exact device that is throwing back the error. The script and similar scripts work on other machines, but when the script contains C#, this machine just doesn't want to play fair.</p>