

This API takes a credential type, and a credential struct, and it produces a string representing the credential. To wedge a certificate into this format, you must use the CredMarshalCredential API. The PSCredential object has only two properties, ‘UserName’ and ‘Password’. Get a certificate inside a PSCredential object However, if your code currently consumes a PSCredential, and you use the user name and password without expecting a certificate credential, you can make the necessary adjustments yourself.Īll the code for this walkthrough can be found here. Most Win32 APIs that support the PSCredential object for credential validation already support certificates. In this post, we take a look at how a certificate credential is marshaled inside a PSCredential object, how you can do this marshaling yourself, and how you can retrieve the original certificate from a PSCredential object supplied to you.

Summary: It’s not a very well-known feature, but the PSCredential object, and the PowerShell Get-Credential cmdlet, both support certificate credentials (including PIN-protected certificates).
