I don't understand why in some cases it's ok to have spaces in parameters and in some cases it's not.
In this example it's ok to have spaces in $file
variable, but not in $path
.
$file = "test file.tar"
$path = "a b\"
New-Item -Path $path -Type Directory
# Make an empty tar file
tar -cf $file -T NUL
# extract it to $path
tar -xf $file -C $path
Gives you
tar.exe: could not chdir to 'a b"'
And most bizarre
tar -xf $file -C `"$path
works just fine.
I'm on Windows 11 and using the default PowerShell 5.1.