title: PowerShell Write-EventLog CmdLet works manually, not in script
body: <p>I am writing a PowerShell script to disable and move users with in AD.  this part works great.  However I would like to log each event in the event log. The cmdlet <code>Write-EventLog</code> works fine when typed manually.</p>
  
  <pre><code>Write-EventLog –LogName ManageAD –Source “ManageUsers Script” –EntryType Information –EventID 1 –Message “This is a test message"
  </code></pre>
  
  <p>However, when I add the cmdlet to the script it errors.</p>
  
  <pre><code>Write-EventLog –LogName ManageAD –Source “ManageUsers Script” –EntryType Information –EventID 1 –Message “User ” + $SAM + " has been disabled"
  
  Write-EventLog : A positional parameter cannot be found that accepts argument 'Scriptâ??'.
  At C:\test\ManageUsers.ps1:12 char:16
  +     Write-EventLog &lt;&lt;&lt;&lt;  â?"LogName ManageAD â?"Source â?oManageUsers Scriptâ?? â?"EntryType Information â?"EventID
   â?"Message â?oUser â?? + $SAM + " has been disabled"
      + CategoryInfo          : InvalidArgument: (:) [Write-EventLog], ParameterBindingException
      + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.WriteEventLogCommand
  </code></pre>
  
  <p>Any suggestions are appreciated.</p>