title: Powershell: Error while creating a PSCredential object using New-Object cmdlet
body: <p>I am using PS Version 5.0</p>
  
  <p>When trying to create a PSCredential object using New-Object cmdlet, I was getting this error:</p>
  
  <pre><code>New-Object : Cannot find an overload for "PSCredential" and the argument count: "2".
  </code></pre>
  
  <p>My PS Code is as below:</p>
  
  <pre><code>[string][ValidateNotNullOrEmpty()] $secureStringPwd = "pass"
  
  $secureStringPwd = $secureStringPwd|ConvertTo-SecureString -AsPlainText -Force
  
  $creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "svcacct", $secureStringPwd
  </code></pre>
  
  <p>As you can see I am converting the password to secure string but still getting an error</p>