title: Passing PSCredential as parameter to script
body: <p>how can I call one script from another script and pass a PSCredential as a parameter?</p>
  
  <p>The code I have is converting the PSCredential to a string with <code>System.Management.Automation.PSCredential</code> as the string value so it doesn't work:</p>
  
  <p>Error:</p>
  
  <pre><code> Cannot process argument transformation on parameter 'cred'. Cannot convert the 
  "System.Management.Automation.PSCredential" value of type "System.String" to type "System.Management.Automation.PSCredential".
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>function getCurrentSequenceNumber([System.Management.Automation.PSCredential]$cred)
  {
      $scriptPath = 'D:\Ave\A\Scripts\UploadPasswordToStorageTable\ReadTableEntity\Read-TableEntity.ps1'
      $argumentList = "-SubscriptionName $SubscriptionName -StorageAccountName $StorageAccountName -TableName $TableName -partitionKey $partitionKey -rowKey $rowKey -Key $Key -CredentialName $CredentialName -cred $cred"
      $currentSequenceNumber = Invoke-Expression "$scriptPath $argumentList"
      return $currentSequenceNumber
  }
  
  $cred = Get-Credential
  $currentSequenceNumber = getCurrentSequenceNumber $cred
  </code></pre>