MicrosoftDocs / PowerShell-Docs

The official PowerShell documentation sources
https://learn.microsoft.com/powershell
Other
2.01k stars 1.58k forks source link

Rename-item is not working for folders with a special charecter [] enclosed #11460

Closed deepakkavety closed 1 month ago

deepakkavety commented 1 month ago

Type of issue

Code doesn't work

Feedback

I am trying to rename few folders that has keywords like [EXTERNAL] in square bracket. Rename-item code doesn't rename the folders.

Page URL

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/rename-item?view=powershell-7.4

Content source URL

https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/7.4/Microsoft.PowerShell.Management/Rename-Item.md

Author

@sdwheeler

Document Id

20e4490a-6f83-7bb5-64ea-db6912156e2e

sdwheeler commented 1 month ago

In PowerShell, [EXTERNAL] is a wildcard expression that matches any of the specific characters in the brackets. See about_Wildcards.

You have to escape the brackets or use the -LiteralPath parameter instead of -Path.