question

GuillaumeArchambault-9092 avatar image
0 Votes"
GuillaumeArchambault-9092 asked YoungYang-MSFT published

Powershell script does not execute when being run in a folder with special character, for example C:\Test'1. If I run the powershell command from there, there is no issue, but executing the ps1 does not work.

Powershell script does not execute when being run in a folder with special character, for example C:\Test'1. If I run the powershell command from there, there is no issue, but executing the ps1 does not work.

I tried it with multiple type of script, on multiple machines and always same behavior. As soon as I rename the folder to remove the special character, it works fine.

windows-server-powershell
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,
As this thread has been quiet for a while, so here is a quick question.Was your issue resolved?
If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
If no, please reply and tell us the current situation in order to provide further help.
Best Regards,
Yang Yang

0 Votes 0 ·

Since this thread has been quiet for a while, we need to do a return visit and confirm whether your problem has been resolved.
If your question has been solved, please don’t forget to mark it as an answer. :)

0 Votes 0 ·
DSPatrick avatar image
0 Votes"
DSPatrick answered

May take some special handling if the apostrophe is really needed.
https://devblogs.microsoft.com/scripting/how-can-i-connect-to-a-folder-when-theres-an-apostrophe-in-the-folder-name/





--please don't forget to Accept as answer if the reply is helpful--




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered RichMatheisen-8856 edited

From "help about_Quoting_Rules":

Quotation marks are used to specify a literal string. You can enclose a string in single quotation marks (') or double quotation marks (").

Having only one single quote doesn't enclose anything. It only denotes the beginning of a literal string.

To run your example, try .\"c:\Test'1\xxx.ps1"


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.