First day of VMware vSphere PowerCLI Automation Course

Today i have been attending the VMware vSphere Automation course for powerCLI. I don´t know how my fellow students think but i think the course could benefit of a little update and get some more content! There are some good resources that have much more information on the internet and also the VMware PowerCLI web with the powerCLI poster etc. The VMware PowerCLI reference book is going to be mine as soon as it comes to Kindle!

One thing i learned on my own with some help from the Internet and a powershell guru is how to recalculate a result and show it in antother unit for example GB instead of MB, the cool part here is that you include the math library to be able to minimize the number of decimals, this can of course be used on any result you want to remake..


Connect-VIServer localhost

Get-Datastore | Select-Object -Property Name, @{Name="FreeSpaceGB";Expression={[math]::Round(($_.FreeSpaceMB/1024),2)}}

so instead of the screendump below

i get the following:

Another thing that can be done with powercli is to set the Mtu for a vmkernel port to enable the jumbo frames support when using ip storage, as i understand this has to be done in some kind of script/cli to enable because it cannot be done in the gui, and also as important, you cannot edit an existing vmkernel port and change the Mtu so if you have set it up with default Mtu you will have to remove and recreate. Do not forget to edit the vSwitch also because if the Mtu is not set on the vSwitch or the physical switches you will not get the benefit of using the larger frames..


$VMHost = Get-VMHost -Name esxi02.test.local
$pnic = (Get-VMhostNetwork -VMHost $VMHost).PhysicalNic[3]
$vSwitch = New-VirtualSwitch -VMhost $VMHost -Nic $pnic.DeviceName -NumPorts 64 -Name vSwitch3 -Mtu 9000

$PortGroup = New-VirtualPortGroup -Name iSCSI -VirtualSwitch $vSwitch
New-VMHostNetworkAdapter -VMHost $VMHost -Portgroup $PortGroup -VirtualSwitch $vSwitch -IP 192.168.20.68 -SubnetMask 255.255.255.0 -Mtu 9000

If i find something cool in my journey in powerCLI tomorrow i will give an update 🙂

Leave a comment

name*

email* (not published)

website