I have one problem with two questions. I have following 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'}},*
When run in my DEV env (powercli session on my desktop connecting to the vSphere sever), everything is fine. When run in PRODUCTION (ie. powercli session on the vSphere server), I get the following error:
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
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.WhereObjectCommand
Q1: What - in the environment setup - would make the script behaves differently? I checked the versions of the powercli ... they're exactly the same.
Q2: Because the above error, I look into the property of the list by running this cmd:
$snapLst = Get-VM vmindev |Get-Snapshot |Get-Member |Findstr Size
SizeGB Property System.Nullable`1[[System.Decimal, mscorlib, Ve...
SizeMB Property System.Decimal SizeMB {get;}
SizeMB is a "decimal" type; why the error complains that it is a "string"?
Thx in advance!