none
PowerShell PSCredential temporarily corrupted after using BITS cmdlets

    Question

  • I have a PowerShell script that uses the *-BitsTransfer cmdlets.  They work fine if I don't use the Credential parameter, but if I do use it, the specified PSCredential object becomes corrupted.  The UserName property gets a string value of the proper length, but all characters have a numeric value of zero.  The password appears to be valid (i.e., GetNetworkCredential().Password returns the correct password).  When I call Start-BitsTransfer for several files, the first transfers successfully, but subsequent files fail with "The format of the supplied security credentials is invalid."  It appears the first transfer corrupts the credential before the next starts.

    Also interesting (and even more frustrating), creating a new PSCredential object with the same username, even at the command prompt or from the next execution of the script, returns the same (or identically) corrupted PSCredential object.  After several minutes, however, I can usually create another valid one.  Calling Get-Credential also seems to work, but requires user input, of course.

    This makes the BITS virtually cmdlets useless as I can never count on being able to create a valid credential.  Any ideas how to fix or get around this?

    Thursday, August 11, 2016 11:41 PM

Answers

All replies