Closed gpduck closed 9 years ago
Hey, Chris, thanks for looking to make things better! As for the error that you are getting -- what is the scenario in which you are getting it? I tried to reproduce an error with Get-DrsVMHostGroup
, but was not able to. You are just trying to get a VMHost group (that maybe has no VMHosts in it)?
Yeah it seems we have a group that doesn't have any hosts in it (which is a whole different problem :)). It looks like the problem is a change in behavior in PowerShell v5. The following works on v4 but not v5:
ipmo drsrule new-object drsrule.vmhostgroup -Property @{ VMHost = $( if($true){ get-process "boo" -ea 0 } ) }
On Mon, Jun 29, 2015 at 8:13 PM Matt Boren notifications@github.com wrote:
Hey, Chris, thanks for looking to make things better! As for the error that you are getting -- what is the scenario in which you are getting it? I tried to reproduce an error with Get-DrsVMHostGroup, but was not able to. You are just trying to get a VMHost group (that maybe has no VMHosts in it)?
— Reply to this email directly or view it on GitHub https://github.com/PowerCLIGoodies/DRSRule/pull/1#issuecomment-116897229 .
Thanks, Chris. Added your update, and a few others (same problem in two other functions, added a changelog, and updated some tests).
I was getting the following error:
New-Object : The value supplied is not valid, or the property is read-only. Change the value, and then try again. At C:\scripts\modules\drsrule\DRSRule.psm1:77 char:11
Not sure if it is due to running PS 5 or PowerCLI 6, but tracked it down to the VMHost property. I think the old syntax was generating some weird PSObject wrapped $null, which the DRSRule.VMHostGroup object was not able to cast correctly.