Hello all. I am creating deployment scripts for AWS Windows 2016 servers. I have added a script in my packerfile.json that is executed as part of the WinRM provisioner and is supposed to create a series of folders and then create an SMB share for each folder.
When I run the script from the server while logged on it runs perfectly, no issues.
When I run the script as part of the AMI provisioner, WinRM, it creates share names with a prefix and suffix which then causes errors later on when a script must use the share name to finish a task. Example same code run from Server and WinRM: New-SMBShare –Name “WFInstall” –Path “D:\TEMPINSTALL” -FullAccess “everyone” Output when run from the server:
Name = WFInstall Output when run from WinRM during the AMI bake:
Name = â€Name WFInstall â€Path
It’s not an error and provisioning finishes as expected but the share names are wrong. I don’t believe it’s a problem with elevated privilege because the script also adds local groups and this works fine. Any ideas?
LOL @ FullAccess. That was just my testing use case, and I have granular security set with NTFS (no everyone) so it should work out.
That’s a good idea, I will try the single quotes and see if it makes a difference. I didn’t think it would be the JSON because it’s simply copying the .ps1 file from GitHub to the local drive before it executes but maybe it’s doing some strange things to the file during the copy.
Lets hope it works, and I was hoping you would get a laugh out of my comment
My thoughts on JSON is that when it executes the script, the double quotes may be confusing things. Just thinking out loud, this certainly is one for “stump the geek”
change your json to force UTF-8 encoding, or try to run it through a validator (i.e. https://jsonlint.com, google “json validator” if links here are forbidden).
It looks like whatever if using the json file is translating the special characters (specifically the - in this case) to arbitrary trash. Without the code that is being annoying, it is hard to determine what exactly is getting trans-coded improperly.
EDIT:
Also, you may not need the ’ at all, that trash translation can also be coming from the ’ or ", Some markdown sites use “ and ”, which is probably also getting translated incorrectly.