Link
#Import-Module VMware.VimAutomation.Core
#如果使用 6.5.0 之前版本,需要先导入模块

Connect-VIServer -Server 192.168.1.1
#连接vCenter

$selectedlocation="Datacenter"
#此处可以设置 Datacenter 名称或者 Cluster 名称以限制范围


Get-VMHost -location $selectedlocation | Get-VirtualSwitch -Standard  | Get-SecurityPolicy | Set-SecurityPolicy -AllowPromiscuous $False
Get-VMHost -location $selectedlocation | Get-VirtualSwitch -Standard  | Get-SecurityPolicy | Set-SecurityPolicy -ForgedTransmits $False
Get-VMHost -location $selectedlocation | Get-VirtualSwitch -Standard  | Get-SecurityPolicy | Set-SecurityPolicy -MacChanges $False

#Get-VMHost -location $selectedlocation | Get-VirtualSwitch -name "vSwitch0" -Standard  | Get-SecurityPolicy | Set-SecurityPolicy -MacChanges $False