Powershell Query...

Soldato
Joined
4 Dec 2003
Posts
2,847
Any idea why remove-item wont delete a cookie file unless you specify it like this...

remove-item '[email protected]`[1`]'

ie if a file doesnt have the [1] (or in fact any number) the remove-item cmdlet works as expected, but if it has the [ it needs this symbol `

?! :)
 
It's because the -path parameter of remove-item accepts wildcard characters and the square brackets are used as part of Powershell wildcard functionality to enter a range of values.

There are two ways around it -

1) escape the square brackets with the backtick as you have done in your example.

2) use the -LiteralPath parameter instead of -Path
 
Back
Top Bottom