8 Replies Latest reply on Jun 30, 2015 1:34 PM by iscloudyhere

    Export DRS rules including DRS groups

    EdZ314 Novice

      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 manually re-entering after DRS disable?

        • 1. Re: Export DRS rules including DRS groups
          LucD Guru
          User ModeratorsvExpertCommunity Warriors
          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: Export DRS rules including DRS groups
            OsburnM Enthusiast

            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!

            • 3. Re: Export DRS rules including DRS groups
              mattboren Master
              vExpert

              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

              • 4. Re: Export DRS rules including DRS groups
                LucD Guru
                Community WarriorsUser ModeratorsvExpert

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

                 

                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: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                • 5. Re: Export DRS rules including DRS groups
                  iscloudyhere Lurker

                  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

                  • 6. Re: Export DRS rules including DRS groups
                    LucD Guru
                    Community WarriorsUser ModeratorsvExpert

                    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: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                    • 7. Re: Export DRS rules including DRS groups
                      vechiattoa Novice

                      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

                      • 8. Re: Export DRS rules including DRS groups
                        iscloudyhere Lurker

                        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