Do You Like Automation? (VMware Only)
Recently I was reviewing my environment and found that many of my VMs are not in any DRS rule. So I was looking an easy way to find missing VMs. Unfortunately I could not find any easy way to accomplish this task but I found an interesting powercli module which could ease my work a bit (Thanks to LUCD Notes)
What you need is to import DRSRule module to your vSphere Powercli. Its pretty easy
1.Download DRSRule modules from github
2.Unzip the folder
3.Copy unzipped DRSRule module folder to your modules directory
4.Import the module using Ïmport-Module .\DRSRule
Once it is imported, you can use many magics with these modules.DRSRule module contains the following cmdlets
New-DrsVMGroup Create a DRS VM group New-DrsVMHostGroup Create a DRS VMHost group New-DrsVMToVMHostRule Create a DRS VM to VMHost rule New-DrsVMToVMRule Create a DRS VM to VM rule Get-DrsVMGroup Retrieve DRS VM groups Get-DrsVMHostGroup Retrieve DRS VMHost groups Get-DrsVMToVMHostRule Retrieve DRS VM to VMHost rules Get-DrsVMToVMRule Retrieve DRS VM to VM rules Set-DrsVMGroup Change a DRS VM group Set-DrsVMHostGroup Change a DRS VMHost group Set-DrsVMToVMHostRule Change a DRS VM to VMHost rule Set-DrsVMToVMRule Change a DRS VM to VM rule Remove-DrsVMGroup Remove a DRS VM group Remove-DrsVMHostGroup Remove a DRS VMHost group Remove-DrsVMToVMHostRule Remove a DRS VM to VMHost rule Remove-DrsVMToVMRule Remove a DRS VM to VM rule Export-DrsRule Save all DRS groups and rules to a JSON file Import-DrsRule Import DRS groups and rules from a JSON file
If you can make a one liner to list VMs which are part of a DRS rule write me please. Have fun
Update :Thanks to my friend Grzegorz, he send me a one-liner to find missing VMs
(get-cluster cluster_name).ExtensionData.ConfigurationEx.group|?{$_.vm}|%{” GROUP $($_.name) found in this cluster”; foreach($currentvm in $_.vm) { (get-view -id $currentvm).name } }
I am going to use following command now.
Get-DrsVMGroup -Name ‘DRSrule_VMS‘-cluster Dev | Set-DrsVMGroup -VM testvm -Append
The above command will append vm called testvm to Dev cluster DRSrule called DRSrule_VMs
Thanks for reading the post… Have a good dayDisclaimer: I have 0 scripting knowledge