I'm trying to use an example that was posted in an article about managing DRS rules with PowerCLI.
Here is what I'm seeing:
PowerCLI C:\Users> New-VIProperty -Name VMnames -ObjectType DrsVMAffinityRule -Value {
>> param($rule)
>> foreach($vm in $rule.VMIDs) {(Get-VM -Id $vm).Name}
>> }
>>
New-VIProperty : 9/17/2013 3:20:24 PM New-VIProperty Could not find Type with Name 'DrsVMAffinityRule'.
At line:1 char:1
+ New-VIProperty -Name VMnames -ObjectType DrsVMAffinityRule -Value {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (DrsVMAffinityRule:String) [New-VIProperty], VimException
+ FullyQualifiedErrorId : Common_CommonUtil_FilterCollection_ObjectNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVI
Property
Can someone explain what I'm doing wrong? I copied the example straight from the blog.
Here is what I see when I check to see what property type names are available:
PowerCLI C:\Users> Get-VIPropertyValidTypeNames dr
TypeName IsManaged VimTypes
-------- --------- --------
DrsRecommendation False VMware.Vim.ClusterRecommendation
DrsVMHostAffinityRule False VMware.Vim.ClusterVmHostRuleInfo
FloppyDrive False VMware.Vim.VirtualFloppy
DrsVMAntiAffinityRule False VMware.Vim.ClusterAntiAffinityRuleSpec
DrsVMAffinityRule False VMware.Vim.ClusterAffinityRuleSpec
CDDrive False VMware.Vim.VirtualCdrom
It appears that the name DrsVMAffinityRule is known, but the New-VIProperty cmdlet is unhappy with something, maybe not really what it's complaining about?
Thanks for any insight into what might be going on.
To clarify for others, you are referring to the module provided in Let’s Make New-VIProperty Easier.
It looks indeed like this is a deficiency in the New-VIProperty cmdlet.
Apparently the help for the cmdlet is not correct when it says "All PowerCLI object types are supported".
Closer inspection showed that the following types are not supported by the New-VIProperty cmdlet, allthough the Get-VIPropertyValidTypeNames function says they are.
DrsVMHostAffinityRule
DrsVMAntiAffinityRule
StartPolicy
DrsVMAffinityRule
TeamingPolicy
TeamingVirtualSwitchPolicy
TeamingVirtualPortGroupPolicy
I would also like to learn the reason why.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference