2010-06-17 47 views
0

我正在運行一個問題我似乎無法使用通過PowerShell社區擴展(v2.0.3782.38614)提供的Read-Archive cmdlet )。PowerShell PSCX讀取存檔:無法綁定參數...問題

這裏是用來表現我遇到的問題砍下樣本:

$mainPath = "p:\temp" 
$dest = Join-Path $mainPath "ps\CenCodes.zip" 
Read-Archive -Path $dest -Format zip 

運行上面產生以下錯誤:

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 

如果我不使用Join-建立傳遞到「讀 - 存檔」的路徑的途徑如下例所示:

$mainPath = "p:\temp" 
$path = $mainPath + "\ps\CenCodes.zip" 
Read-Archive -Path $path -Format zip 

從以上:

ZIP Folder: CenCodes.zip#\ 

Index   LastWriteTime   Size Ratio Name                      -----   -------------   ---- ----- ---- 
0   6/17/2010 2:03 AM  3009106 24.53 % CenCodes.xls 

更加混亂的,如果我的比較結果爲上述兩個讀存檔樣品中的路徑參數傳遞的兩個變量,他們似乎相同:

這...

Write-Host "dest=$dest" 
Write-Host "path=$path" 
Write-Host ("path -eq dest is " + ($dest -eq $path).ToString()) 

輸出...

dest=p:\temp\ps\CenCodes.zip 
path=p:\temp\ps\CenCodes.zip 
path -eq dest is True 

任何人有任何想法,爲什麼第一個樣本抱怨但S第二個工作正常嗎?

回答

1

我在PSCX的CodePlex主頁的問題跟蹤器中創建了一個項目。顯然這是PscxPathInfo目前已知的問題。 (請參閱PSCX問題跟蹤器中的item #28023)。

一個解決辦法是要做到這一點:

Get-Item $dest | Read-Archive 

感謝CodePlex上r_keith_hill該特定變通。