Tuesday, April 26, 2016

DISABLING NETFLOW WITH POWERCLI

Great script for viewing and disabling Vmware Netflow on a VDPortgroup, the below was a couple of quick and dirty scripts to first of all list all VDPortgroups and if they have Netflow enabled, the second was to disable Netflow for a VDPortgroup or a number of VDPortgroups.
This may help with a known issue on ESXi 5.1 when Netflow is enabled:http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2042370


List all VDPortGroups and if Netflow is enabled

Get-VDPortgroup | Select Name, VirtualSwitch, @{Name="NetflowEnabled";Expression={$_.Extensiondata.Config.defaultPortConfig.ipfixEnabled.Value}}

Function Disable-PGNetflow {
   [CmdletBinding()]
   Param (
      [Parameter(ValueFromPipeline=$true)]
      $DVPG
   )
   Process {
      Foreach ($PG in $DVPG) {
         $spec = New-Object VMware.Vim.DVPortgroupConfigSpec
         $spec.configversion = $PG.Extensiondata.Config.ConfigVersion
         $spec.defaultPortConfig = New-Object VMware.Vim.VMwareDVSPortSetting
         $spec.defaultPortConfig.ipfixEnabled = New-Object VMware.Vim.BoolPolicy
         $spec.defaultPortConfig.ipfixEnabled.inherited = $false
         $spec.defaultPortConfig.ipfixEnabled.value = $false
 
         $PGView = Get-View -Id $PG.Id
         $PGView.ReconfigureDVPortgroup_Task($spec)
      }
   }
}
 
# Disable Netfow for a VDPortgroup
Get-VDPortgroup DPortGroup | Disable-PGNetflow




No comments:

Post a Comment

Vmware NSX SSL creation 

Using OpenSSL for NSX Manager SSL import: Creates CSR and 4096 bit KEY Creating NSX 6.4.2 SSL    openssl req -out nsxcert.csr -newkey rsa:40...