Remote Monitoring & Management Help

PowerShell: the use of $ and other special characters in the password

Consideration must be given when passing passwords that contain special characters through PowerShell to ensure they are handled as literal strings.

For example, if the password contains a dollar sign ($) it must either be preceded by a grave accent ` (also known as a backtick: ASCII code 96 - Alt+96) or the password encapsulated in single ' ' to pass the password to PowerShell exactly as entered.

Password Example

String

Result

pas$word

pas

pas`word

pas$word

'pas$word'

pas$word

Where the password contains a special character (in this example dollar sign) but no preceding grave accent, or is not encapsulated in single quotes, the message Failed to connect Credentials invalid is returned.

Some PowerShell special characters are themselves constructed using a grave accent so should be encapsulated in single quotes when passed via the Script and these are covered in the Microsoft Technet article: about_Special_Characters

What do you want to do?

Please be aware that we are not responsible for the content of external sites.