PowerShell – Get-Credential with a + (Plus) in the User Name

I have recently been working with an API that auto generates the user name to be used with it. The user name generated by the API contains a “+” character which doesn’t work with Get-Credential as it seems to fail the inbuilt validation of that CMDlet.

get-credential get-credential_-username

The code you’ll see below will allow you to use a username with a “+” in it and a secure string for a password.

Get-Credential Work Around

I created a function to be used in the module I was writing which you will also see below.


About the author

Ben Taylor

Cloud and PowerShell enthusiast with a penchant for automation and CI.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *