我有一个问题有两个问题。我有以下 powercli cmd:
$snapLst = Get-VM vmindev |Get-Snapshot |Select VM, Name, Description, `
@{Name='Created'; Expression={{$_.Created.ToString("yyMMdd")}}, `
@{Name='SizeMB'; Expression={[int] $_.SizeMB}}
$resultLst=$snapLst| where SizeMB -gt 1000 |Sort-Object SizeMB |`
Select @{Name='Type'; Expression={'BIG'}},*
Run Code Online (Sandbox Code Playgroud)
当在我的 DEV 环境(连接到 vSphere 服务器的桌面上的 powercli 会话)中运行时,一切都很好。在生产环境中运行时(即 vSphere 服务器上的 powercli 会话),我收到以下错误:
Where-Object : Cannot bind parameter 'FilterScript'. Cannot convert the "SizeMB" value of type "System.String" to type System.Management.Automation.ScriptBlock".
At C:\Users\kness\Scripts\sn2.ps1:32 char:27
+ $resultLst=$snapLst| where <<<< SizeMB -gt 1000 |Sort-Object SizeMB |Select
@{Name='Type'; Expression={'BIG'}},
+ CategoryInfo : InvalidArgument: (:) [Where-Object], ParameterBindingException …Run Code Online (Sandbox Code Playgroud)