title: Unexpected token errors in Powershell
body: <p>I'm working on a script to change local security policy in windows server. When I run these commands by themselves in a PowerShell prompt, they work fine. However when I run the script I am getting an <code>"Unexpected token 'PasswordComplexity' in expression or statement."</code> error.</p>
  
  <p>The problem seems to stem from the fact that the script doesn't seem to be executing the <code>secedit</code> command, so the <code>get-content</code> lines have no file to edit.</p>
  
  <p>Why is <code>secedit</code> not running? I've tried putting the <code>secedit</code> command outside of the <code>if</code> statement, but get the same results.</p>
  
  
  
  <pre class="lang-powershell prettyprint-override"><code>if ($win_ver -match "Server"){
      #export current secuirty policy
      secedit /export /cfg c:\new.cfg
      start-sleep -s 10
      #Disable Password Complexity
      ((get-content c:\new.cfg) -replace (‘PasswordComplexity = 1′, ‘PasswordComplexity = 0′)) | Out-File c:\new.cfg
      #Disable password expiration
      ((get-content c:\new.cfg) -replace (‘MaximumPasswordAge = 42′, ‘MaximumPasswordAge = -1′)) | Out-File c:\new.cfg
      #disable minmum password length
      ((get-content c:\new.cfg) -replace (‘MinimumPasswordLength = 6′, ‘MinimumPasswordLength = 1′)) | Out-File c:\new.cfg
      #import new security settings
      secedit /configure /db $env:windir\security\new.sdb /cfg c:\new.cfg /areas SECURITYPOLICY
  }
  </code></pre>