2017-02-20 56 views
-1

下面是我對UCSPowerShell的問題爲UCS

Remove-Item F:\Logs\UCS\* 
$server= Read-Host -Prompt 'Please enter UCS IP' 
$Chasis= '(ChassisId 1)' 
connect-UCS $server 
Get-UcsTechSupport -PathPattern 'F:\Logs\UCS\${ucs}-techsupp-chassis.tar' -RemoveFromUcs -TimeoutSec 1200 -$Chasis -CimcId all 

我得到以下錯誤,當我嘗試運行它的腳本..

Get-UcsTechSupport : A positional parameter cannot be found that accepts argument '-ChassisId 1'. 
At F:\Logs\ucs1.ps1:5 char:1 
+ Get-UcsTechSupport -PathPattern 'F:\Logs\UCS\${ucs}-techsupp-chassis.tar' -Remov ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : InvalidArgument: (:) [Get-UcsTechSupport], ParameterBindingException 
    + FullyQualifiedErrorId : PositionalParameterNotFound,Cisco.Ucs.Cmdlets.GetUcsTechSupport 
+0

請格式化你的代碼。 (http://stackoverflow.com/help/formatting) – Chostakovitch

回答

0

你的問題是這樣的:

-$Chasis 

可以解決的問題:

-(ChassisId 1) 

要特別注意連字符(-

PS是看到這個作爲名稱的參數的

我不知道你正在使用的小命令的參數,所以這個糾正代碼只是一個例子:

... -TimeoutSec 1200 -ParameterName $Chasis -CimcId all 
+0

它不會混淆參數名稱,它具有位置分配問題。由於在cmdlet調用中沒有爲該值命名的參數,因此PowerShell將嘗試在位置上進行匹配。 'Get-UcsTechSupport'不支持這個錯誤。 – Matt

+0

感謝馬特的答覆.. –

+0

Get-UcsTechSupport -PathPattern'F:\ Logs \ UCS \ $ {ucs} -techsupp-chassis.tar'-RemoveFromUcs -TimeoutSec 1200-ChassisId 1 -CimcId all - 這對我來說工作正常。但我想在變量中調用底盤號碼,以便它可以接受輸入,當我嘗試此操作時,它會返回錯誤 –