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 LICENSE NUMBERS, ACTIVATION 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.
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
PGomersall
Posts: 138
Last visit: Thu Apr 11, 2024 7:51 am

Formatinng issue with curly brack brace in path

Post by PGomersall »

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
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: Formatinng issue with curly brack brace in path

Post by mxtrinidad »

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\

:)
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.