我正在使用New-Item
cmdlet 创建一个新文件夹,但令人惊讶地发现它没有-Literalpath
可用的参数。我的路径中包含方括号。我能做些什么来解决这个问题?
问问题
1024 次
1 回答
1
所以,真正的问题是什么有点令人困惑。因此,您需要转义括号,就像在字符串中转义“\n”一样- 使用“`”。这将创建文件夹:
> New-Item -Path 'C:\stuff\powershell\`[test`]' -Name "221" -ItemType "directory"
但这将“默默地失败”:
> New-Item -Path 'C:\stuff\powershell\[test]' -Name "221" -ItemType "directory"
于 2019-01-15T11:50:50.297 回答