I'm quite new to Powershell and I'm using the Get-Hash cmdlet:

This works:

PS M:\> Get-Hash -Path "C:\Users\medmondson\Desktop\New Folder\database.adp" -Algorithm SHA512

This fails:

PS M:\> Get-Hash -Path "C:\Users\medmondson\Desktop\New [Folder]\database.adp" -Algorithm SHA512
Get-Hash : Cannot bind argument to parameter 'Path' because it is an empty array.

I understand this is likely due to the square brackets in the path [] which are valid under windows operating systems. So how do I get powershell to escape these?

有帮助吗?

解决方案

Try to use ` backtick to escape the square bracket and enclose the whole string in single quote.

PS M:\> Get-Hash -Path 'C:\Users\medmondson\Desktop\New `[Folder`]\database.adp' -Algorithm SHA512
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top