New Year and new things to learn

I promised myself to try and post at least once a month and I totally missed December.  Well it was a totally crazy month and I have tons to post on my learning over the last number of weeks.

On the 16th and 17th, I took a course on PowerCLI automation for Administrators course.  Kudos to Joe Christie from VMware whom instructed the course.  It was a good learning experience and I picked up tons in the class for how to do stuff with Powershell.  I still find the programming language slow to process the commands in comparison to other languages but it is simpler in many ways to trying to duplicate your work using the GUI.

I was wanting many times over to automate a ESXi Build process and finally built a script in which I cut and paste to the Power Shell CLI to build the machine quickly and efficiently.
Note the < > , these are to signify that they need customizing for your environment...

$vHost = "<Set your VMHostnane here>"
$vMotionIP = "<Set your IP for your vMotion portgroup>"

$switch = New-VirtualSwitch $vHost -Name vSwvMotion -Nic vmnic3

New-VirtualPortGroup -Name vMotion -VirtualSwitch $switch
New-VMHostNetworkAdapter $vHost -PortGroup vMotion -VirtualSwitch $switch -IP $vMotionIP -SubnetMask -VMotionEnabled $true

#build virtual machine vswitch/portgroup
Get-VMHost $vHost | New-VirtualSwitch -name "vSwVMLAN" -nic vmnic1,vmnic4
Get-VMHost $vHost | Get-VirtualSwitch -name "vSwVMLAN" | New-VirtualPortGroup "<PG Name>" -VLanId <vlanID>
Get-VMHost $vHost | Get-VirtualSwitch -name "vSwVMLAN" | New-VirtualPortGroup
"<PG Name2>" -VLanId 100

Get-VMHost $vHost | New-VirtualSwitch -name "vSwVMDMZ" -nic vmnic5
Get-VMHost $vHost | Get-VirtualSwitch -name "vSwVMDMZ" | New-VirtualPortGroup "<DMZ Portgroup>" -VLanId <vlanID>

#Add NTP Server to Host
Add-VmHostNtpServer -VMHost $vHost -NtpServer "<NTP Server IP>"

#add second nic to Management Team
$vs = get-virtualswitch -name vSwitch0 -vmhost $vHost
set-virtualswitch -virtualswitch $vs -nic vmnic2,vmnic0

#Change the local Datastore Name from datastore1 to Local:<servername>
$DSName = "Local:$vHost"
Set-Datastore -Datastore datastore1 -Name $DSName

#configure DNS and Gateway for vmkernel
$dns1 = "<dns Primary IP>"
$dns2 = "
<dns Secondary IP>"
$domain = "<Domain Name>"

$vmhostnetwork = get-vmhostnetwork $vHost
Set-VMHostNetwork -network $vmhostnetwork -vmkernelgateway <Management Port IP GW> -Domain $domain -SearchDomain $domain -Dnsaddress $dns1,$dns2 -confirm:$false

#Add NFS Datastores
New-Datastore -Nfs -VMHost $vHost -Name <Name for Datastore ex. NFS:ISO> -Path "<NFS_Path>" -NfsHost <NFSHostIP>

This is an example of the learning from a guy that had "limited" knowledge of powershell to writing my own scripts and running commands instead of figuring out the GUI.