Need to change the NetworkFailoverDetectionPolicy for all your vSwithes and portgroups? The following script traverses all clusters and host to check the NetworkFailoverDetectionPolicy for Beacon Probing. If its Beacon Probing, change it to Link Status.
#import-module VMware.VimAutomation.Core
#Connect-VIServer -Server vcenter_hostname
#uncomment for testing
#$vmhosts = "hostname1","hostname2"
#uncomment for live run
#get the hostnames of all the hosts in every cluster
$vmhosts = get-cluster | get-vmhost | select name
foreach($vmhost in $vmhosts)
{
#Gets all the vSwitch names that has beacon probing set on the host.
$switch_policy = Get-VirtualSwitch -VMHost $vmhost.Name | where {$_.Name -ne "vSwitchiDRACvusb"} | Get-NicTeamingPolicy | Where-Object {$_.NetworkFailoverDetectionPolicy -eq "BeaconProbing"} | select -ExpandProperty VirtualSwitch # | select VirtualSwitch | format-wide
if ($switch_policy)
{
foreach ($switch in $switch_policy)
{
$vs = Get-VirtualSwitch -VMHost $vmhost.Name -Name $switch
Get-NicTeamingPolicy -VirtualSwitch $vs | Set-NicTeamingPolicy -NetworkFailoverDetectionPolicy LinkStatus
}
}
#Gets all the port group names that has beacon probing set on the host.
$portgroup_policy = Get-VirtualPortGroup -VMHost $vmhost | Get-NicTeamingPolicy | Where-Object {$_.NetworkFailoverDetectionPolicy -eq "BeaconProbing"} | select -ExpandProperty VirtualPortGroup
if ($portgroup_policy)
{
foreach ($p in $portgroup_policy)
{
#Sets the nicteamingpolicy from the host and its portgroup.
$vpg = Get-VirtualPortGroup -VMHost $vmhost.Name -Name $p
Get-NicTeamingPolicy -VirtualPortGroup $vpg | Set-NicTeamingPolicy -NetworkFailoverDetectionPolicy LinkStatus
}
}
}
No comments:
Post a Comment
Thank you for your comment.