title: Troubleshoot Powershell script inside Chef recipe
body: <p>I'm fairly new to Chef but I've gone through all the online tutorials and feel like I have a decent grasp on the basics. I'm trying to run a Powershell script from inside a recipe. The script itself runs fine from Powershell and updates the DNS IP settings as expected. When I run the recipe it also completes without error but the embedded script does't update the DNS settings so I'm assuming it's not executing properly and I'm not sure where to look for errors/logs. </p>
  
  <p>The recipe is posted below and is executed via <code>chef-client.bat --local-mode --runlist 'recipe[prod_server::dns_settings]'</code></p>
  
  <pre><code>   powershell_script 'Set DNS Servers' do
    code = &lt;&lt;-EOH
    $primary = "10.1.10.2"
       $secondary = "10.1.10.225"
       $DNSServers = "$primary","$secondary"
       $message=""
      function setDNS($DNSServers)
      {
         try
          {
            $NICs = Get-WMIObject Win32_NetworkAdapterConfiguration |where{$_.IPEnabled -eq "TRUE"}
            Foreach($NIC in $NICs)
         {
           $message += $NIC.SetDNSServerSearchOrder(@($DNSServers)) | Out-String   # set the DNS IPs and capture output to string
         }
            }
         catch
            {
        $message += "An error occcured while setting NIC object." + "`n`rError: $_";
            }
         #write-host $message #if necessary, display result messages
      }
      setDNS($DNSServers)
    EOH
       end
  </code></pre>