Say I have the following two paths (both are valid, say):
$p1 = "D:\folder1\"
$p2 = "D:\Folder1"
I want to compare these two paths for equality. I am expecting both paths to be the same. I tried both the commands below:
(Resolve-Path $p1) -eq (Resolve-Path $p2) Get-Item $p1) -eq (Get-Item $p2) None returned $True because the backslash was not normalized. Now I know I can do some regex magic and make it work but all I am looking for is an in-built solution for comparing file paths.
join-path "C:\Windows" ""
join-path "C:\Windows\" ""
Both return "C:\Windows\" since join-path normalizes them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With