Cleaning up Standard Switches with PowerCLI after migrating to VDS

PowerShell and PowerCLI are such a wonderful tools for so many things. I want to share a very simple 'one-liner' that saved me a good amount of time when removing a bunch of Standard Switches from hosts on various vCenters.

Recently I was tasked with migrating hosts and their VMs on a few vSphere environments from Standard Switches to the Virtual Distributed Switch on their corresponding vCenters; the migration part wasn't hard, hosts were added to VDS, then the VMs were hot migrated using the built-in "Migrate Virtual Machine Networking" option of the VDS. Once all was set and done, the Standard Switches and their port-groups, which there were many, needed to be cleaned up, but manually removing one Switch at the time from several hosts wasn't a smart way of doing it - simple from the GUI yes, but not ideal if you have large amount of hosts with a handful of VSS each. So the one-liner that allowed me to remove all Standard Switches from all nodes at once was: 

Remove-VirtualSwitch -VirtualSwitch vSwitch1, vSwitch2, vSwitch3, vSwitch4 -Server vCenterServerName -Confirm:$false 

The syntax for this command allows to enter multiple VSS names separated by comas which is key for removing all intended switches in one shot. Parameter -Confirm:$false avoided the prompt for every deletion and the -Server vCenterServerName option is only required if you are connected to more than one vCenter Server on the current PowerCLI session. You should obviously use caution and test before running a command like this against your production vCenter Server, the -WhatIf parameter is very helpful to confirm that what you want to accomplish with the command is what the result will be.




Automating Windows Patches on Templates

Back in 2015, I posted a use case on the VMware Communities that described a process I implemented to keep various Windows Templates up to date with Microsoft patches on multiple vSphere 5.5 environments.
It was common to run into situations where a virtual machine would be deployed from a template and it was way behind on Microsoft patches; this incurred additional time to bring the server up-to-date, time that could've been used in better ways.


For those managing multiple sites and not running vSphere 6.x which provides the ability of using Content Libraries where a single or less quantity of templates can be kept updated and shared with Subscribed Libraries (vCenters), this solution may still be applicable.

The Tasks involved: Convert template to VM, power on VM, run Windows Update remotely, reboot VMGuest, shut VM down and finally convert back to template.

What's required on Templates:

  • Server 2008/2012 Templates need to be running PowerShell v.3 minimum but v.4 is highly recommended. 
    • PowerShell 4 for 2008 server can be downloaded here 
  • The Windows Update PowerShell Module needs to be installed on your templates. 
    • It can be downloaded from here

Note: The Windows Update PowerShell Module includes the command
Get-WUInstall which is what I used to initiate patch installations remotely (from the script).


How to embed your Twitter Timeline on your blog or website.

Last night, the vBrowngBagLATAM crew had a session about how to start your own blog, tips and tricks. During the discussion, my new blog was shown and there were questions about how to embed your own Twitter timeline into the blog or website. Here are the steps I used, they are very simple.

Visit https://publish.twitter.com/ and enter your Twitter handle or that of the user you want to embed.


Select the "Embedded Timeline" option on the left.

Hello World!

My name is Jorge and this is my first attempt at blogging. After debating for some time if it was a good idea for me to engage in a venture of writing about technology, considering I live a busy work/family life and have never blogged before, I figured it was worth trying it, particularly since recent events have shown me that when you share knowledge, you may not only help others but actually learn a bunch yourself and become better at it. -- It's my hope :-)

My initial intention here is to share different experiences I may come across at work, on the lab or stuff discussed with colleagues and techie friends around the world that may interest and help others.

I also hope for this to be an opportunity to engage with like-minded IT professionals and more experienced individuals from whom I could gain and improve skills as I continue to grow professionally.

--