PoshCode Archive  Artifact Content

Artifact 87040b8138ba0d745842101936fa09063e40f3bb9b6fd314fa02cf39aff8df73:

  • File Set-vSphere-CDP-LinkDisc.ps1 — part of check-in [3a3ee8ff34] at 2018-06-10 12:58:43 on branch trunk — A script to set the CDP settings for vsphere. Note that LLDP is an option in vSphere, but it doesn’t work. Here’s hoping for the future! (user: unknown size: 1283)

# encoding: ascii
# api: powershell
# title: Set vSphere CDP LinkDisc
# description: A script to set the CDP settings for vsphere. Note that LLDP is an option in vSphere, but it doesn’t work. Here’s hoping for the future!
# version: 0.1
# type: function
# license: CC0
# function: set-vSwitchLinkDiscovery
# x-poshcode-id: 1583
# x-archived: 2010-01-22T06:04:52
#
#
function set-vSwitchLinkDiscovery {
    Param (
        #Switch to enable vSwitch Discovery On
         [Parameter(Mandatory=$true,ValueFromPipeline=$true)]$vSwitchName
        #Host on which the vSwitch Resides
        ,[Parameter(Mandatory=$true,HelpMessage="")][string]$VMBackupDestination,
    ) #Param

	#Variables
	$vSwitchName = "vSwitch0"
	$linkProtocol = "cdp"
	$linkOperation = "both"
	$VMHost = "myhost"

	#Get the specification for the vSwitch
	$networkview = (get-vmhostnetwork -vmhost $VMHost | get-view)
	$vSwitchSpec = ($networkView.NetworkConfig.vSwitch | Where {$_.Name -eq $vSwitchName}).Spec

	#Set Protocol Type and Operation
	$vSwitchSpec.Bridge.LinkDiscoveryProtocolConfig.protocol = $linkProtocol	$vSwitchSpec.Bridge.LinkDiscoveryProtocolConfig.operation = $linkOperation

	#Commit Changes
	$networkview.updateVirtualSwitch($vSwitchName,$vSwitchSpec)
}