- This topic has 5 replies, 3 voices, and was last updated 3 months, 1 week ago by
February 19, 2020 at 7:58 pm #204675
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?
February 19, 2020 at 9:05 pm #204702ParticipantTopics: 6Replies: 93Points: 428Rank: Contributor
Maybe it is trying to tell you FullAccess for everyone is a bad idea 🙂
I would suspect the issue is with JSON. Have you tried using single quotes?
New-SMBShare –Name ‘WFInstall’ –Path ‘D:\TEMPINSTALL’ -FullAccess ‘everyone’
PS does not need them in this case.
February 19, 2020 at 9:18 pm #204705
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.
- This reply was modified 3 months, 2 weeks ago by Mark_ODO.
February 19, 2020 at 9:34 pm #204714ParticipantTopics: 6Replies: 93Points: 428Rank: Contributor
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”
February 20, 2020 at 3:40 pm #204912
Nope, the single quotes didn’t work. The output shows that it just adds the single quote to the Name:
Name = â€Name ‘WFInstall’ â€Path
February 20, 2020 at 5:27 pm #204951ParticipantTopics: 1Replies: 20Points: 109Rank: Participant
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.
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.
- This reply was modified 3 months, 1 week ago by p42p0wd3r.
- The topic ‘Error: WinRM provisioner & New-SMBShare share names are wrong’ is closed to new replies.