PowerCLI 5.1 R2 Released

PowerCLIVersionVMware have just released PowerCLI 5.1 R2 and with it are the long awaiting cmdlets to work with VDS!

I worked with these a little and although VDS are not 100% fully covered in this release the cmdlets are certainly useful for most of the things I needed to do and they opened up VDS with the .extensiondata property for the rest of the things I wanted to play with.

Two of the cooler cmdlets where the Export-VDSwitch and New-VDSwitch –backupfile which can be used with 5.1 and the new VDS features to backup the VDS into a simple zip file and re-import it when needed.

I have included the new cmdlets and some examples from the help file below.

As well as the VDS cmdlets I am also happy that VMware now supports PowerShell v3 and vCloud Director 5.1 in both their admin version of PowerCLI and their Tenant version, this opens up vCD to automate some of the cooler new features of VCD and also enable the enhancements made by Microsoft in PowerShell v3.

Download it now.

VDS Cmdlets and their examples

Get-VDSCommand

Lists all the PowerCLI cmdlets available for VDS

Get-VDSCommand

Add-VDSwitchPhysicalNetworkAdapter

Retrieves the specified physical network adapter from the specified host and adds it to the specified distributed switch.

$vmhostNetworkAdapter = Get-VMHost "MyVMHost" | Get-VMHostNetworkAdapter -Physical -Name vmnic2
Get-VDSwitch "MyVDSwitch" | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter

Add-VDSwitchVMHost

Adds two hosts to the specified distributed switch.

Get-VDSwitch -Name "MyDistributedSwitch" | Add-VDSwitchVMHost -VMHost "VMHost1", "VMHost2"

Export-VDPortGroup

Exports the configuration of the specified port group to the specified file.

Get-VDPortGroup -Name 'MyVDPortGroup' | Export-VDPortGroup -Destination 'C:\MyVDSwitchesBackup\MyVDPortGroup_21122012.zip'

Exports the configuration of the specified port group to the specified file. If the MyVDSwitchesBackup directory does not exist, it is created. If the MyVDPortGroupBackup.zip file already exists in the specified location, it is overwritten.

$myPortGroup = Get-VDPortGroup -Name 'MyVDPortGroup'
Export-VDPortGroup -VDPortGroup $myPortGroup -Destination 'C:\MyVDSwitchesBackup\MyVDPortGroupBackup.zip' -Force

Export-VDSwitch

Exports the configuration of the specified vSphere distributed switch and its port groups to the specified file.

Get-VDSwitch -Name 'MyVDSwitch' | Export-VDSwitch -Description "My VDSwitch configuration" -Location "c:\myVDSwitchConfig.zip"

Exports the configuration of the specified vSphere distributed switch and its port groups to the specified file. If the myVDSwitchConfig.zip file already exists, it is overwritten.

Get-VDSwitch -Name 'MyVDSwitch' | Export-VDSwitch -Description "My VDSwitch configuration" -Location "c:\myVDSwitchConfig.zip" -WithoutPortGroups -Force

Get-VDPortgroup

Retrieves the distributed port group named “MyVDPortGroup” on the specified vSphere distributed switch.

Get-VDPortGroup -Name "MyVDPortGroup" -VDSwitch "MyVDSwitch"

Retrieves the distributed port groups that are related to the specified organization network in the cloud.

Get-OrgNetwork -Name "MyOrgNetwork" | Get-VDPortGroup

Retrieves the distributed port group to which the specified virtual machine network adapter is connected.

Get-NetworkAdapter -Name "MyVMNetworkAdapter" | Get-VDPortGroup

Get-VDSwitch

Retrieves all vSphere distributed switches in the specified datacenter.

Get-Datacenter -Name MyDatacenter | Get-VDSwitch

Retrieves all vSphere distributed switches to which the specified host is added.

Get-VMHost -Name MyVMHost | Get-VDSwitch

Retrieves all vSphere distributed switches to which the specified virtual machine is connected.

Get-VM -Name MyVM | Get-VDSwitch

New-VDPortgroup

Creates a new distributed port group on the specified vSphere distributed switch with the specified number of ports and VLAN ID.

Get-VDSwitch -Name "MyVDSwitch" | New-VDPortgroup -Name "MyVDPortGroup" -NumPorts 8 -VLanId 4

Creates a new distributed port group on the specified vSphere distributed switch by cloning the configuration of the distributed port group named “MyReferencePortGroup”.

$myReferncePortroup = Get-VDPortgroup -Name "MyReferencePortGroup"
Get-VDSwitch -Name "MyVDSwitch" | New-VDPortgroup -Name "MyVDPortGroup" -ReferencePortgroup $myReferncePortroup

Creates asynchronously a new distributed port group on the specified vSphere distributed switch.

Get-VDSwitch -Name "MyVDSwitch" | New-VDPortgroup -Name "MyVDPortGroup" -RunAsync

Creates a new distributed port group on the specified vSphere distributed switch by importing the specified backup profile.

$myBackupFilePath = 'c:\Backup.zip'
Get-VDSwitch -Name "MyVDSwitch" | New-VDPortgroup -Name "MyVDPortgroup" -BakupPath $myBackupFilePath

Creates a new distributed port group on the specified vSphere distributed switch with the specified name and VLAN trunk range settings.

Get-VDSwitch -Name "MyVDSwitch" | New-VDPortgroup -Name "MyVDPortGroup" -VlanTrunkRange "1-5, 10-20"

New-VDSwitch

Creates a new vSphere distributed switch with the specified name, version, maximum number of ports, and link discovery protocol settings in the specified datacenter.

$myDatacenter = Get-Datacenter -Name "MyDatacenter"
New-VDSwitch -Name "MyVDSwitch" -Location $myDatacenter -LinkDiscoveryProtocol "LLDP" -LinkDiscoveryProtocolOperation "Listen" -MaxPorts 256 -Version "5.0.0"

Creates a new vSphere distributed switch by cloning the configuration of the existing distributed switch named “MyReferenceSwitch”. The new distributed switch is created without cloning the existing port groups and is stored in the specified folder.

$myFolder = Get-Folder -Name "MyFolder"
Get-VDSwitch -Name "MyReferenceSwitch" | New-VDSwitch -Name "MyVDSwitch" -Location $myFolder -WithoutPortGroups

Creates a new vSphere distributed switch by importing the specified backup profile.

$myFolder = Get-Folder -Name "MyFolder"
New-VDSwitch -Name "MyVDSwitch" -Location $myFolder -WithoutPortGroups -BackupPath "c:\MyDistributedSwitchProfile.zip"

Remove-VDPortGroup

Removes the specified distributed port group from the vSphere distributed switch that it belongs to.

Get-VDPortGroup -Name "MyVDPortGroup" | Remove-VDPortGroup

Remove-VDSwitch

Removes the specified distributed switch.

Get-VDSwitch -Name MyVDSwitch | Remove-VDSwitch

Remove-VDSwitchPhysicalNetworkAdapter

Removes the specified host physical network adapter from the distributed switch that it is connected to.

Get-VMhost -Name "MyVMhost" | Get-VMHostNetworkAdapter -Physical -Name vmnic0 | Remove-VDSwitchPhysicalNetworkAdapter

Remove-VDSwitchVMHost

Removes two hosts from the specified distributed switch.

Get-VDSwitch -Name "MySwitch" | Remove-VDSwitchVMHost -VMHost "VMHost1", "VMHost2"

Set-VDPortgroup

Changes the name, number of ports and the VLAN ID of all distributed port groups named “MyVDPortGroup”.

Get-VDPortgroup -Name "MyVDPortGroup" | Set-VDPortgroup -Name "MyNewVDPortGroupName" -NumPorts 5 -VlanId 4

Changes the VLAN trunk range of all distributed port groups named “MyVDPortGroup”.

Get-VDPortgroup -Name "MyVDPortGroup" | Set-VDPortgroup -VlanTrunkRange "1-5, 8-10"

Sets the VLAN type of the specified distributed port group to None.

$myVDPortgroup = Get-VDPortgroup -Name "MyVDPortGroup" -VDSwitch "MyVDSwitch"
Set-VDPortgroup -VDPortgroup $myVDPortgroup -DisableVlan

Rollbacks the configuration of all distributed port groups named “MyVDPortGroup”.

Get-VDPortgroup -Name "MyVDPortGroup" | Set-VDPortgroup -RollbackConfiguration

Reconfigures all distributed port groups named “MyVDPortGroup” by importing the configuration from the specified backup profile.

Get-VDPortgroup -Name "MyVDPortGroup" | Set-VDPortgroup -BackupPath 'c:\backup.zip'

Set-VDSwitch

Modifies the maximum number of ports, the number of uplink ports, and the maximum MTU size of the specified vSphere distributed switch.

Get-VDSwitch -Name "MyVDSwitch" | Set-VDSwitch -MaxPorts 1000 -NumUplinkPorts 8 -Mtu 2000

Changes the version of all vSphere distributed switches whose names start with “MyVDSwitch”.

$myVDSwitches = Get-VDSwitch -Name MyVDSwitch*
Set-VDSwitch -VDSwitch $myVDSwitches -Version '5.1.0'

Enables link discovery protocol on the specified vSphere distributed switch, sets it to LLDP and changes the link discovery protocol operation to listen.

$myVDSwitch = Get-VDSwitch -Name "MyVDSwitch"
Set-VDSwitch -VDSwitch $myVDSwitch -LinkDiscoveryProtocol LLDP -LinkDiscoveryProtocolOperation Listen

Reconfigures the specified vSphere distributed switch by importing the specified backup profile. The original port groups are not recreated.

Get-VDSwitch -Name "MyVDSwitch" | Set-VDSwitch -BackupPath 'c:\MyVDSwitchBackups\MyVDSwitch_12_12_2012.zip' -WithoutPortGroups

Rollbacks the configuration of the specified vSphere distributed switch to its previous state.

Get-VDSwitch -Name "MyVDSwitch" | Set-VDSwitch -RollbackConfiguration

3 thoughts on “PowerCLI 5.1 R2 Released

  1. Pingback: Powershell v3 and PowerCLI | vmdude

  2. Pingback: Powershell v3 et PowerCLI | vmdude

  3. Pingback: vCloud 5.1 API Support in PowerCLI 5.1 R2 « Geek after Five

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.