PowerCLIGoodies / DRSRule

PowerShell module with support for managing vSphere DRS Rules and Groups
28 stars 9 forks source link

Errors when importing from previously exported VMHost group #23

Open mtboren opened 5 years ago

mtboren commented 5 years ago

Opening new issue from comment from user @gillx0101 (original comment here)

Can someone help! I'm able to use the export-drsrule successfully, but get errors when importing the txt file with the following;

Get-DrsRuleObject : Cannot validate argument on parameter 'Object'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At C:\Program Files\WindowsPowerShell\Modules\DRSRule\2.0.0\DRSRule.psm1:1572 char:38

... _filtered | Get-DrsRuleObject -Type 'ClusterAffinityRuleSpec|ClusterA ...


CategoryInfo : InvalidData: (:) [Get-DrsRuleObject], ParameterBindingValidationException
FullyQualifiedErrorId : ParameterArgumentValidationError,Get-DrsRuleObject
I am using Powercli VMware PowerCLI 11.3.0 build 13990089 and verion 2.0.0 of the DRSRule.

I am testing with vcentre 6.7, creating a test VM/Host group, exporting out then deleting from vmware and trying to import back in from the export file. Any pointers would be appreciated.> 
mtboren commented 5 years ago

Hello, @gillx0101

A few things to help us understand what might be happening here:

gillx0101 commented 4 years ago

Thanks @mtboren for taking a look. I am using a Windows 10 client with PS 5.1 installed. Below is the output running with the "ShowOnly" switch

PS C:\WINDOWS\system32> Import-DrsRule d:\temp\drs.txt -ShowOnly
Method invocation failed because [System.Management.Automation.PSCustomObject] does not contain a method named
'GetEnumerator'.
At C:\Program Files\WindowsPowerShell\Modules\DRSRule\2.0.0\DRSRule.psm1:1557 char:7
+       $arrRuleObjects_filtered = $ruleObjects.GetEnumerator() | Where ...
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (GetEnumerator:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

Not sure if I follow your last point? I created a VM Host Group with a name "DRSHost", but when I tried to export got the following:

PS C:\WINDOWS\system32> Export-DrsRule -Name DRSHost

cmdlet Export-DrsRule at command pipeline position 1
Supply values for the following parameters:
Path: d:\temp\drshstsgroup.txt
Unable to find type [DRSRule_VMToVMRule].
At C:\Program Files\WindowsPowerShell\Modules\DRSRule\2.0.0\DRSRule.psm1:271 char:15
+   [OutputType([DRSRule_VMToVMRule],[VMware.Vim.ClusterAffinityRuleSpe ...
+               ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (DRSRule_VMToVMRule:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

I think its worth noting I also get the above intermittently when just running an export-drsrule and providing a path for the output ??