title: A positional parameter cannot be found that accepts argument-System.Management.Automation.PSCredential'-Error
body: <p>I have a script which needs to run from remote by passing on credentials in the script as as below:-</p>
  
  <pre><code>$UserName = Read-Host "Enter User Name:" 
  $Password = Read-Host -AsSecureString "Enter Your Password:" 
  $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $UserName , $Password 
  
  
  Set-Service -Name HiTrust -StartupType Automatic -ComputerName ServerName -credential $Credential 
  (Get-Service  -Name "HiTrust" -credential $Credential -ComputerName ServerName).Start() 
  Exit
  </code></pre>
  
  <p>However I keep on getting error as below:-</p>
  
  <blockquote>
  <pre><code>Set-Service : A positional parameter cannot be found that accepts argument 'System.Management.Automation.PSCredential'.
  At C:\Users\ucub\Desktop\Test.ps1:9 char:15
  + ...             Set-Service -Name HiTrust -StartupType Automatic -Compute ...
  +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidArgument: (:) [Set-Service], ParentContainsErrorRecordException
      + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetServiceCommand
  </code></pre>
  </blockquote>