VMware Cloud Community
EdZ314
Enthusiast
Enthusiast

Export DRS rules including DRS groups

I'm looking for a way to export a listing of DRS groups. I found some scripts that will export/import DRS rules, but they ony apply to affinity/anti-affinity for VMs - like these:

http://ict-freak.nl/2009/08/28/powercli-export-import-and-create-drs-rules/

Is there any way to export the DRS host/vm group information and the rules for running VM's on specific hosts?

Also found these scripts as well

Re: Backup/Restore DRS VM affinity/anti-affinity rules - can these be backed up and restored without...

8 Replies
LucD
Leadership
Leadership

Have a look at Matt's Backup/Export Full DRS Rule Info via PowerShell


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
OsburnM
Hot Shot
Hot Shot

LucD wrote:

Have a look at Matt's Backup/Export Full DRS Rule Info via PowerShell

Anyknow know if he ever posted an update blog on Restor/Import?  I need to move a datacenter/cluster from one vcenter to another and this would be extremely helpful.  DRS Affinity Rules are easy... The DRS Group Creation/Member adds that need to come first are where I'm stuck.

Thanks!

Reply
0 Kudos
mattboren
Expert
Expert

Hello, OsburnM-

Yes, I know:  he never did write a subsequent post for restoring/importing rules from the exported "full" DRS rule info.

I also know:  he just today took a bit of time to write the code for such things.  And, he I will write that subsequent post in the next day or two, and include this new code for "importing" from the exported rule info.  I will update this thread once I have made said post.  Until then, happy holidays.

Matt

LucD
Leadership
Leadership

Since your question triggered it, you might be interested to know that  and myself posted the DRSRule module today, including import and export cmdlets :smileycool:

Have a look at our posts on the subject: DRSRule - New PowerShell Module for DRS Rule and Group Management and DRSRule – a DRS rules and groups module


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

iscloudyhere
Contributor
Contributor

Hi LucD and mattboren

Left you a message in your blog entry, hope you can give me a reply

I am experiencing this error using pcli6 connected to VC 5.1@

Get-DrsVMtoVMRule : Unable to find type [DRSRule.VMToVMRule]. Make sure that

the assembly that contains this type is loaded.

At C:\Program Files\VMware\Infrastructure\vSphere

PowerCLI\Modules\DRSRule\DRSRule.psm1:1066 char:9

+        (Get-DrsVMtoVMRule @hshParamsForGetCall),

+         ~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (DRSRule.VMToVMRule:TypeName)

   [], RuntimeException

    + FullyQualifiedErrorId : TypeNotFound

Reply
0 Kudos
LucD
Leadership
Leadership

Does your $PSModulePath variable contain the folder where you stored the DRSRule files ?

How did you load the module ? Implicit or auto-load ?

Which PowerShell version are you using ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
vechiattoa
Contributor
Contributor

Hi Luc. I have the same problem. follows the error when the import module.

Windows Powershell 4.0

Powercli 5.8 Release 1

Add-Type : (0) : Metadata file '\VMware\Infrastructure\vSphere PowerCLI\VMware.Vim.dll' could not be found

(1) :   using VMware.Vim;

At C:\Users\n813114\Documents\WindowsPowerShell\Modules\DRSRule\DRSRule.init.ps1:3 char:1

+ Add-Type -ReferencedAssemblies $pcliDll -TypeDefinition @"

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidData: (error CS0006: M...ld not be found:CompilerError) [Add-Type], Exception

    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand

Add-Type : Cannot add type. Compilation errors occurred.

At C:\Users\n813114\Documents\WindowsPowerShell\Modules\DRSRule\DRSRule.init.ps1:3 char:1

+ Add-Type -ReferencedAssemblies $pcliDll -TypeDefinition @"

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidData: (:) [Add-Type], InvalidOperationException

    + FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand

Reply
0 Kudos
iscloudyhere
Contributor
Contributor

Hi Luc,

Thanks for your reply.

I tried to import the module and also copy the files to the folder for auto load using powershell 4.

Regards

Reply
0 Kudos