ucs的Powershell问题

ucs的Powershell问题,powershell,Powershell,下面是我的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 -Cim

下面是我的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
你的问题是:

-$Chasis
决议如下:

-(ChassisId 1)
请特别注意连字符(
-

PS将其视为参数的名称

我不知道您正在使用的CmdLet的参数,因此更正后的代码只是一个示例:

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

请格式化您的代码。()它不会混淆参数名称,因为它与位置分配有问题。由于cmdlet调用中没有为该值命名的参数,PowerShell将尝试在位置上匹配该参数
Get-UcsTechSupport
不支持这一点,因此出现错误。Get-UcsTechSupport-PathPattern'F:\Logs\UCS\${UCS}-techsupp chassis.tar'-RemoveFromUcs-TimeoutSec 1200-ChassiId 1-CimcId all-这对我来说很好。但我想在变量中调用Chassis number,以便它可以接受输入,当我尝试此操作时,它将返回错误