Formatinng issue with curly brack brace in path

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
PGomersall
Posts: 92
Joined: Sun Mar 03, 2013 12:40 pm

Formatinng issue with curly brack brace in path

Post by PGomersall » Fri Feb 09, 2018 2:36 pm

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: PowerShell Studio 2018 v5.5.148
32 or 64 bit version of product: 64 bit
Operating system: W10 1709
32 or 64 bit OS: 64 bit

*** Please add details and screenshots as needed below. ***
PS 2018 auto formats path pasted in, to add spaces if it contain curly brackets as in GPO Policy GUI in sysvol. Not sure if this was issue in prior versions.
Here is a test, paste following into a ps1 script:
\\domain.local\sysvol\donain.local\Policies\{FF26B629-AC16-47DD-B538-369271FA858A}\User\Scripts\Logon\
PS 2108 reformats to add a space after opening { and before closing }:
\\domain.local\sysvol\donain.local\Policies\{ FF26B629-AC16-47DD-B538-369271FA858A }\User\Scripts\Logon\
Obviously the path is now incorrect, only way I could fix it was with back tick `

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

User avatar
mxtrinidad
Site Admin
Posts: 373
Joined: Sun Mar 03, 2013 12:42 pm

Re: Formatinng issue with curly brack brace in path

Post by mxtrinidad » Fri Feb 09, 2018 3:20 pm

This behavior is normal when you paste directly into the editor empty line. It also happens in Windows ISE Editor.

You need to create the string placeholder, using either Single or Double quotes. ... Preferably Single-quotes to keep the consistency of the string. This way will save the value correctly.

Single-quotes => 'place-copied-string-here' (Prefer)
'\\domain.local\sysvol\donain.local\Policies\{FF26B629-AC16-47DD-B538-369271FA858A}\User\Scripts\Logon\'

Double-quotes => "place-copied-string-here"
"\\domain.local\sysvol\donain.local\Policies\{FF26B629-AC16-47DD-B538-369271FA858A}\User\Scripts\Logon\"

Just pasting the string, in this case, will add the space thinking is a PowerShell scriptblock:
\\domain.local\sysvol\donain.local\Policies\{ FF26B629-AC16-47DD-B538-369271FA858A }\User\Scripts\Logon\

:)