Workaround for a password var with Special Character '&'

Hi, I am trying to get packer to build but when i use a production password with the ‘&’ character in use it wont set in Windows and winrm wont kick off, if i remove the character it works, I dont really have the option of changing my production password.
Any advice?

Have you tried to escape the character yet? I’m assuming you’re setting a variable, and passing that variable on to the packer config HCL/JSON file.

apologies, am new to this coding shtuff, what does that mean? not sure if it makes any diff but the character is slap bang in the middle of the password??

Maybe I read your initial query incorrectly.

So you’re trying to set the password for the windows build using a password that has the ampersand in it? And when you try to use that password to connect to WinRM, it won’t connect to the device?

I don’t think it’s an issue in/with packer, but may be an issue with the password being set in Windows. I was able to connect to a machine using the following WinRM password:

DKVD!mHHhZbxCQVbECf%%cwQqPXJ&PCzVS^g8C&ntgy9GhTx*@Mn37CjohhDvAYHgv*jF7sx*LQKw642H&T9KYSpcGPygVexTidue

This was just a test, so I was using it against a the “null” builder. Can you provide a sanitized version of your HCL/JSON config file?

Hey, thanks for getting back to me, in the mean time i tried a number of things.
The script i have customised is based on the “packer example for vmware, it appears the password which is something like “dsagj&1024CAR!p0” and if i remove the “&” and regenderate the encrypted password and ssh key, it works perfectly, it appears the script is not parsing the password correctly.
I tried escape codes of “",”\”,and "\" as well as \u0026 but to no avail. i have raised the issue with my manager along the lines of “do we have an emergency password change |” routine :smiley:

based on this script, as a test all i did was update to point to my lab, and using existing creds in config, just changing the password, GitHub - vmware-samples/packer-examples-for-vsphere: Packer Examples for vSphere