How to Migrate VMs to New vCenter using PowerCLI

I faced this same question recently in my work environment. I was taking over the management of some infrastructure for a remote site, along with adding new hardware. The existing hardware was in a standalone vCenter, and the new hardware was connected to our enterprise vCenter. Lucky for me, the standalone vCenter was version 6.7 and has the ability to run the PowerCLI cross vCenter migrations.… Continue reading

PowerCLI to Remove VM Tags

Using VM tags to logically group VMs is awesome, but they can come a time when you need to remove the tags to apply a different one. Using the web console can be very time consuming. PowerCLI to the rescue.

Remove-TagAssignment

Using Remove-TagAssignment is powerful. You can use it to target just a single tag to be removed from a list of VMs.… Continue reading

How to Recovery VMs on a Defective Host?

How to recover from a host failure when DRS didn’t help because it wasn’t enabled, that is a good question. Normally HA will kick in and move the workload from one host to another upon failure. This morning, our HA agent must have slept in. SMH. When I got into the office virtually this morning, I found that I had a host failure, and 57 VMs went down with the ship thinking they were the captains.… Continue reading

PowerShell to Get OS Type and Count

My manager asked for the count of Windows Server 2012 virtual servers. So I did a fast and dirty script to get just the count of Server 2012

$server2012 = ((get-vm).extensiondata.guest | Where GuestFullName -eq "Microsoft Windows Server 2012 (64-bit)").count

After I provided the results from this, I worked to make it a better, more robust script.… Continue reading

Automate Removal of VM Snapshots

Automate Removal of VM Snapshots

When I come up with an idea for a blog post, normally I don’t review what ideas I have already wrote about.  I should because I would have noticed another post about snapshots I wrote earlier this year.  This post is different as it has more cowbell, err automation.  Everybody loves automation right? … Continue reading

How to add a VM to Content Library using PowerCLI

This task sounds very simple.  Target the VM, then import to the primary content library for replication to the subordinate libraries.  This task can be accomplished right now with a few clicks in the GUI.  I’m not a GUI kind of person, I like the mash the keys to get stuff done.  So after a lot of research, I found that the PowerCLI commands to perform this function just don’t exist at this point.… Continue reading

Generating VM Tags with PowerCLI

Generating VM Tags with PowerCLI

With the our new infrastructure upgrade it also included an upgrade to our backup solution.  So we now have EMC Avamar for backups, and with this it means a chance to architect the backup solution the best possible way.  So during the initial stage, I worked closely with our storage team to get the method that they chose to work. … Continue reading

PowerCLI to get Virtual to Physical CPU Ratio

PowerCLI to get Virtual to Physical CPU Ratio

I was in a meeting today, and was asked, “What is the current virtual to physical CPU ratio?”  I didn’t have an answer for this question, so I asked PowerCLI for the answer.

[PS]
(get-cluster $ClusterName | Get-vm | Where Powerstate -eq “PoweredOn” | Measure NumCpu -sum).sum / (((Get-cluster $ClusterName | Get-vmhost).extensiondata.summary.hardware… Continue reading

Removing Snapshots with PowerCLI

Snapshots for Maintenance or Maintenance for Snapshots…

During our last maintenance window for our VMware environment, my team updated VMware Tools, hardware and aligned vNUMA.  So before we started this work we took snapshots of all of the VMs there were getting the updates.  Fast forward a few days, and now we have 600+ snapshots that need to be deleted.… Continue reading

PowerCli to Increase Hardware on Multiple VMs

The other night I had a task of upgrading 22 VMs with additional vCPUs and memory.  I also had a maintenance window of 60 minutes to get this completed.  So I wasn’t going to do this more than once, so I just wrote a simple PowerCli script that would handle this process for me.

So this script starts off identifying the servers that the work is going to be performed on.… Continue reading