Author Archives: admin

Using PowerCLi to Export and Import OS Customization Specs

I was asked to find a solution to automate importing OS customization Specs to our Vcenters. Its a task that not difficult but better if was scripted. I found this code located at ForwardorReverse blog. Export function allows you to export the OS customization Spec to $secname.xml and the import allows you to import them. These two functions are few years old according to the Blog but still work on Vsphere 6.5 without issue.

Function Export-OSCustomizationSpec {
    param (
        [string]$exportFile = "$specname.xml"
    $csmgr = Get-View CustomizationSpecManager
    if ($csmgr.DoesCustomizationSpecExist($specName)) {
        $spec = $csmgr.GetCustomizationSpec($specName)
        $csmgr.CustomizationSpecItemToXml($spec) | Out-File $exportFile
    else {
        throw "Spec $specName not found"
Function Import-OSCustomizationSpec {
    param (
        [string]$specName #Use to change the spec name from that defined in the file
    $specXml = Get-Content $importFile
    $csmgr = Get-View CustomizationSpecManager
    $spec = $csmgr.XmlToCustomizationSpecItem($specXml)
     # Change the name if a new one was given.
    if ($specName) {
        $spec.Info.Name = $specName
     if ($csmgr.DoesCustomizationSpecExist($spec.Info.Name)) {
        throw "Spec $specName already exists."
    else {

Creating vSAN cluster with over 32 hosts

So I was building out a 44 node vSAN cluster last week and I ran into an issue where 12 of the ESXi hosts had their own network Partition group different than the other 32.  I had no issues with the vSAN network, I was able to use vmkping every server so there was no communication issue with any of the hosts in the cluster  via the vSAN kernel.  In most cases vSAN Network partitioning occurs when there was issue with vSAN kernel communicating with other hosts.

After several attempts of removing the diskgroups, removing vSAN kernel, moving out of cluster and away from DVS then back I had no luck.  I knew based on VMware supported Maximum that I could create a 64 node vSAN cluster.  I was at a loss so after several hours troubleshooting and Google searching I ended up opening a SR with VMware after about hour or so troubleshooting the VMware engineer was at loss until he found an article that indicates that you must create some advanced settings on the ESXi hosts in order to see above 32 nodes and once we made those settings rebooted the hosts we had a single network partition our issue was resolved.

The KB article (2110081) shows how to perform task via esxcli via SSH logged into root but does not show how to do it via PowerCli.

$vcenter = Read-Host "Enter Vcenter connecting to"

Connect-VIserver $vcenter

$cluster = Read-host "Cluster Name"

foreach ($host in (Get-Vmhost -Location $cluster)){
Get-VMhost $host | Get-AdvancedSetting -Name "VSAN.goto11" | Set-AdvancedSetting -value 1 -confirm:$false
Get-VMhost $host | Get-AdvancedSetting -Name "Net.TcpipHeapMax" | Set-AdvancedSetting -value 1536 -confirm:$false

Then reboot your hosts.

That’s it!

You would think that supported maximums would occur out of box but according to VMware they did not want smaller vSAN cluster to sacrifice memory overhead that would be required for larger vSAN clusters to run efficiently.

Migrate VMs to another ESXi host in another Vcenter

Can across situation where I needed to move VM from one Vcenter to another.

The following script will do the following:
Will prompt for a Source and Target Vcenter and then ask for user credentials.
Connect to the Source and Target Vcenter. When then cycle through VMs listed from csv file (VMList.csv). (Place the csv file in same directory as the script.)

The list of VMs in the One by one and Migrate the VM to new VC. If the VMs powered on will attempt to shutdown the Server (if VMtools installed) and t

The format of the VMList.csv file needs to be in format as below.

#ensure that not connected to any vCenters
Disconnect-VIServer -Server * -Force -Confirm:$false

#enter Vcenter
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Scope User -Confirm:$false
$vc1 = Read-Host "Enter Source Vcenter"
$vc2 = Read-Host "Enter Target Vcenter"

Write-Host "VC1 = " $vc1
Write-Host "VC2 = " $vc2

$vmlist = Import-CSV “$pwd\VMList.csv”

# Connect To Vcenter Server
$User = Read-Host -Prompt "Please enter your VC admin username"
$PW = Read-Host -Prompt "Please enter your VC admin password" -asSecureString
$PW = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($PW))

Connect-VIServer $vc1 -User $User -Password $PW -ErrorAction SilentlyContinue
Connect-VIServer $vc2 -User $User -Password $PW -ErrorAction SilentlyContinue

foreach ($item in $vmlist) {
# Map variables
$vm = $item.vmName
$destESXi = $item.targetesxihost
$destDatastore = $item.targetdatastore
$destVDSwitch = $item.targetDVSwtich
$destPortgroup= $item.targetPortGroup
$typeDisk = $item.Disktype

$vm = get-vm $vm
#Check to see if VM powered off if powered on will shutdown and check ever 5 sec til shutdown
if ($vm.powerstate -eq "PowerdOn"){
write-host "Shutting down" $vm
$vm | Shutdown-VMguest -Confirm:$false
do {
#wait 5 secs
start-Sleep -s 5
$vm = get-vm $vm
$status = $vm.powerstate
}until($status -eq "PoweredOff")

Write-Host "===== Connected vCenters ====="
$global:DefaultVIServers | ft -AutoSize

#Command to migrate the VM to new Host in new Vcenter
Write-Host "Moving VM" $vm
Move-VM -VM (Get-VM -Server $vc1 -Name $vm) -VMotionPriority High `
-Destination (Get-VMHost -Server $vc2 -Name $destESXi) `
-Datastore (Get-Datastore -Server $vc2 -Name $destDatastore) -DiskStorageFormat $typeDisk `
-PortGroup (Get-VDPortgroup -Server $vc2 -VDSwitch $destVDSwitch -Name $destPortgroup)

} #end of ForLoop

Disconnect-VIServer -Server * -Force -Confirm:$false

Amazon Fire TV Cube after one week

After little over a week of using the Amazon Fire TV Cube. I’ve been very happy with it my purchase so far. By far from control perspective I really love how the voice command to turn on and off my TV/Sound bar works very well without use of a remote. It does a good job launching applications via voice but I’ve seen voice commands within the app is not as great. For pausing and restarting video works good. But asking it to play a specific TV series in Hulu for example (when there are multiple user profiles requires interaction with remove to select profile and sometimes locate the TV show. It does a great job controlling my netgear arlos cameras, and all the other smart devices in the home.

Some of features that I feel that this device is lacking is the ability to control off the air TV antenna (don’t have cable to use voice command to control cable box). I also wish that it had full features of a typical echo, such as drop (to use as home intercom system). In addition to improvements anytime you issue your voice command it will pause the Video that you are playing (lets say that you want volume up or down) it will pause the video and adjust the volume and then continue. This may be something I just need to get use to not issue just a little annoying.

Overall I would recommend this to anyone especially those who have an older Fire TV (I had the original Fire TV), and those who don’t want a dongle and device with more horse power than a fire TV Stick. For controlling a main TV/Sound bar in living its great feature to be able to control with voice. As the most importing approval the wife seems also to embrace the device for her approval too.

New Amazon Fire TV Cube

Amazon has new Fire TV device called the Fire TV Cube.  I Pre-Ordered mine today for $89.99.  I’m an owner of the original Fire TV for my main TV in our house.  I’ve wanted to upgrade my Fire TV for quite some time b/c it was lacking many of the features that the Fire TV 4k had to offer but I did not want a dongle hanging from my TV but rather a piece of hardware that  had more horse power and performance like the original Fire TV had vs the Fire TV Stick.

The retail price of this unit is $119.99 but if you pre-order you can get it now for $89.99.  The ship date for this new device is June 21st.

Here is full description of the product from Amazon site:

  • Fire TV Cube is the first hands-free streaming media player with Alexa, delivering an all-in-one entertainment experience. From across the room, just ask Alexa to turn on the TV, dim the lights, and play what you want to watch.
  • With far-field voice recognition, eight microphones, and beamforming technology, Fire TV Cube hears you from any direction. Enjoy hands-free voice control—search, play, pause, fast forward, and more. Plus, control your TV, sound bar, cable or satellite box, receiver, and more with just your voice.
  • Do more with Alexa. Fire TV Cube has a built-in speaker that lets you check the weather, listen to the news, control compatible smart home devices, and more—even with the TV off. Fire TV Cube is always getting smarter with new Alexa skills and voice functionality.
    Experience true-to-life picture quality and sound with access to vivid 4K Ultra HD up to 60 fps, HDR, and the audio clarity of Dolby Atmos.
  • Enjoy tens of thousands of channels, apps, and Alexa skills. Get over 500,000 movies and TV episodes from Netflix, Prime Video, Hulu, HBO, SHOWTIME, NBC, and more.
  • Access YouTube, Facebook, Reddit, and more websites with Silk and Firefox browsers.