I'm running across a problem I can't seem to wrap my head around using the Read-Archive cmdlet available via PowerShell Community Extensions (v2.0.3782.38614).
Here is a cut down sample used to exhibit the problem I'm running into:
$mainPath = "p:\temp"
$dest = Join-Path $mainPath "ps\CenCodes.zip"
Read-Archive -Path $dest -Format zip
Running the above produces the following error:
Read-Archive : Cannot bind parameter 'Path'. Cannot convert the "p:\temp\ps\CenCodes.zip" value of type "System.String" to type "Pscx.IO.PscxPathInfo".
At line:3 char:19
+ Read-Archive -Path <<<< $dest -Format zip
+ CategoryInfo : InvalidArgument: (:) [Read-Archive], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Pscx.Commands.IO.Compression.ReadArchiveCommand
If I do not use Join-Path to build the path passed to Read-Archive it works, as in this example:
$mainPath = "p:\temp"
$path = $mainPath + "\ps\CenCodes.zip"
Read-Archive -Path $path -Format zip
Output from above:
ZIP Folder: CenCodes.zip#\
Index LastWriteTime Size Ratio Name ----- ------------- ---- ----- ----
0 6/17/2010 2:03 AM 3009106 24.53 % CenCodes.xls
Even more confusing is if I compare the two variables passed as the Path argument in the two Read-Archive samples above, they seem identical:
This...
Write-Host "dest=$dest"
Write-Host "path=$path"
Write-Host ("path -eq dest is " + ($dest -eq $path).ToString())
Outputs...
dest=p:\temp\ps\CenCodes.zip
path=p:\temp\ps\CenCodes.zip
path -eq dest is True
Anyone have any ideas as to why the first sample gripes but the second one works fine?