Pergunta

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?

Foi útil?

Solução

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top