title: How to pass the password as argument in Powershell script and convert to secure string
body: <p>I am using below powershell script to execute</p>
  
  <pre><code>param([string]$Server,[string]$locusername,[string]$locpassword)
  
  $password = '$locpassword' | ConvertTo-SecureString -asPlainText -Force
  $username = $locusername 
  $cred = New-Object System.Management.Automation.PSCredential($username,$password)
  </code></pre>
  
  <p>and i am getting error</p>
  
  <blockquote>
    <p>Cannot bind argument to parameter 'String' because it is null.
        + CategoryInfo          : InvalidData: (:) [ConvertTo-SecureString], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand</p>
  </blockquote>