gooly
gooly

Reputation: 1341

PowerShell Text-Replace Pwd with special char


I have a password with special char (in a PSObject):

  "Pwd" = "ng%h?k^jh$ert"

Now to login I need to handle this as a string!
How do I protect e.g. $ ($ert) and all the other special char for being evaluated, interpreted, or changed?

Thanks in advance
Gooly

Upvotes: 0

Views: 89

Answers (1)

notjustme
notjustme

Reputation: 2494

Try using single quotes instead and see how far that takes you.

"Pwd" = 'ng%h?k^jh$ert'

If the password contained the character ' you'd be in a similar problem again though but that could be handled with escape chars;

"Pwd" = "ng%h?`'k^jh`$ert"

Upvotes: 2

Related Questions