title: Change logon account of a service using powershell when password has special symbols
body: <p>I'm running following powershell script to change logon user account of a remote service and then start it.</p>
  
  <pre><code>$result = $remoteService.Change($null,$null,$null,$null,$null,$null,$logonAccount, $logonPassword,$null,$null,$null)
  
      if ($result.ReturnValue -eq '0') 
      {
          write-host "logon account changed"
          $remoteService.StartService();
      } 
      else 
      {
          write-host "Error: $result.ReturnValue"
      };
  </code></pre>
  
  <p>If my password contains only alphanumeric chars, I can see that service starts as shown in result below</p>
  
  <pre><code>logon account changed
  ReturnValue      : 0
  </code></pre>
  
  <p>However another account includes password with special characters like @, # and - , if I use this account my service start fails with error code 15.</p>
  
  <pre><code>logon account changed
  ReturnValue      : 15
  </code></pre>
  
  <p>Same is the result of I use sc command (example)</p>
  
  <pre><code>sc \\servername config servicename obj= domain\accountname password= w@e#dF-sxs32
  sc \\servername  start servicename
  
  [SC] StartService FAILED 1069:
  The service did not start due to a logon failure.
  </code></pre>
  
  <p>I can manually change the logon user of service and start it successfully from the Windows services.msc UI using the same account as mentioned above. So I thought issue could be with the password.</p>
  
  <p>I have struggled a lot with this. can anyone please help. 
  Thanks</p>