Hey everyone! I'm diving into some automation and I'm trying to pass a password as a string from a YAML config file into PowerShell. Here's the thing: it works perfectly when the string is just:
fnsdjkfnsdkjfnsdkjfndjkn`@?[]]_^;:=
But when I add an '>' at the end, everything just goes haywire and the script fails, probably because it's seen as an output redirect.
So my question is: should I be escaping characters in the YAML file itself and just hoping PowerShell handles it right, or should I be doing any necessary escape or replace operations within the script? Also, is there a smarter way to handle the '>' character? Oh, and I noticed that when I put in '^', it seems to just vanish, but the script runs fine without it. Thanks for the help!
1 Answer
It sounds like your main issue is about how you're passing those strings to your PowerShell script. If your script is set up correctly with parameters, it should handle special characters like '>' without crashing. Just make sure it's parameterized well!
Gotcha! So the string is in a YAML file that a .NET app parses to call your script, right? If everything loads properly, there might be a trick with escaping characters in the input. You might want to double-check how the parameters are formatted in your script.