Tag Archives: vsphere

vSphere: Enable/Disable DRS Host rules with PowerCLI

I know that the latest version of PowerCLI already have commandlet to will enable/disable DRS host rules. But when you are in operations, you don’t really get to use the latest version of PowerCLI all the time. Anyway, this is just a placeholder for myself, but if you find it useful great for you.

Disclaimer: This is not my original work, I forgot where I ripped the codes from, but its not my original work. Apologize for the bad formatting.

#Filename = Set-DRSVMHostRules.ps1

$cluster = Get-Cluster 
$ClusName $rule = $cluster | 
  Get-DrsRule -Type VMHostAffinity -Name $RuleName 
$spec = New-Object VMware.Vim.ClusterConfigSpec
$ruleSpec = New-Object VMware.Vim.ClusterRuleSpec 
$ruleSpec.Info = $rule.ExtensionData 
$ruleSpec.Info.Enabled = $Enable 
$ruleSpec.Operation = "edit" 
$spec.rulesSpec += $ruleSpec 

$cluster.ExtensionData.ReconfigureCluster($spec,$true) | Out-Null
$cluster | Get-DrsRule -Type VMHostAffinity -Name $RuleName

get-cluster ClusterABCDC | Get-DrsRule -Type VMHostAffinity | 
% { .\Set-DRSVMHostRules.ps1 -ClusName $_.cluster -RuleName $ -Enable $true}
Leave a comment

Posted by on July 21, 2019 in powershell, vmware


Tags: , ,

RP4VM failover testing network

Updated this article after Peter’s comments and my own testing

During failover of an RP4VM consistency group (CG), you have a few choices of selecting the test network to failover your VMs in. Why is this necessary?


Read the rest of this entry »


Posted by on May 18, 2017 in Cloud, vmware


Tags: , , ,

Unswapping swapped mem in Vsphere 6.0

An interesting article from yellow bricks on an undocumented feature in Vsphere 6.0 to allow you to swap out memory after contention is long gone. Previously, you either had to power cycle or vmotion your VM to get back memory into RAM.

However, my advice is always to avoid over-commit of memory as the last resort and manage the size your VM to avoid over-commit whenever possible. Ballooning and memory swapping into disk is one of the most performance hit activities that can happen to your environment compared or over-committing on CPU.



Leave a comment

Posted by on June 3, 2016 in vmware


Tags: ,

Powershell: Batch removing datastores from ESXi hosts (4.1)

We have to repurpose a bunch of 10 ESXi host for another purpose and I need to remove all the 12 datastores already mounted on the hosts. Here is a one-liner which I used to remove datastores quickly using vsphere powershell CLI commands. Note hosts.txt and ds.txt contains a list of hosts and datastores which you want to remove. Broke down into paragraphs for readability, this should be a one-liner. This is for 4.1 hosts. 5.0 host and beyond may require a different command due to storage I/O controls.

get-content c:\scripts\hosts.txt |

% { $h = $_ ; get-content c:\scripts\ds.txt |

%{ "Host="+$h+" : Removing Datastore... "+$_ ;

remove-datastore -Datastore $_ -VMhost $h -confirm:$false}}

Leave a comment

Posted by on June 27, 2013 in powershell, Scripts, vmware


Tags: , ,