Disabling Netflow with PowerCLI

Today I was asked if there was a script to disable 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}}


Disable Netflow for a VDPortgroup or a number of VDPortGroups

Function Disable-PGNetflow {
	Param (
	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

# Disable Netfow for a VDPortgroup
Get-VDPortgroup DPortGroup | Disable-PGNetflow




Alan Renouf has a role of Automation Frameworks Product Manager at VMware responsible for providing the architects and operators of the cloud infrastructure with the toolkits/frameworks and command-line interfaces they require to build a fully automated software-defined datacenter. Alan is a frequent blogger at http://blogs.vmware.com/vipowershell and has a personal blog at http://virtu-al.net. You can follow Alan on twitter as @alanrenouf.

You may also like...

2 Responses

  1. July 26, 2013

    [...] … [...]

  2. July 28, 2013

    [...] Alan Renouf показывает, как отключить Netflow на порт-группе с помощью PowerShell. [...]

Leave a Reply

%d bloggers like this: