PowerShell: Unable to write data to a UNC path that contains square brackets

Question:

This is the problem I’m having:

I have already checked my permissions and I definitely have permission to write to the network share. The problem only happens when I use the “LiteralPath” parameter, which, unfortunately, is required for what I’m doing.

How can I write data to a UNC path that contains square brackets?

Answer:

you will find on Microsoft web site an explanation about strange behaviours of ‘sqare brackets‘ in PowerShell expressions.

BUT

When I just write the following (without brackets) it just does’t work for me :

but (according to Microsoft article) the following works

I tried to solve this trouble with PowerShell Drive

And it was even worst

Turn arround solution 1 :
I solve it using :

And then the followwing works

Turn arround solution 2 : using FileInfo

I think that the explanation is that in -literalpath UNC are poorly supported

Source:

PowerShell: Unable to write data to a UNC path that contains square brackets by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply