I have Powershell v5 running in Windows 10 64Bit OS.
And I also have a nice trick to make the paths with square brackets compatible to be read by Powershell by escaping with tilde signs like $Path.Replace('[','
[' ).Replace(']',']')
, so intuitively I thought, why not make it a function like below for the same:
Function GetEscapedPath($Path) {
Return $Path.Replace('[','`[' ).Replace(']','`]')
}
Now I want to use this function return value as input to Remove-Item
function or any File-fullpath based functions for that matter, but this doesn't work:
Remove-Item GetEscapedPath $File.Fullname -WhatIf
$File
is variable from loop on Get-ChildItem
with Fullname
selected, but still the above line doesn't print anything.
How can I achieve what I want ?