Visitors

PowerCLI: Average CPU, Memory, Network and Disk usage

This simple PowerShell/PowerCLI script calculates the average CPU, Memory, Network and Disk usage for powered on virtual machines over the last 30 days, 5 minutes interval.

Amend ‘AddDays(-N)‘ and ‘-IntervalMins 5‘ if needed.

Get-VM | Where {$_.PowerState -eq "PoweredOn"} | Select Name, Host, NumCpu, MemoryMB, ` @{N="CPU Usage (Average), Mhz" ; E={[Math]::Round((($_ | Get-Stat -Stat […]

Configure DHCP reservation with Powershell

Quick Powershell script to add DHCP reservation for a VM on multiple DHCP servers:

Please refer to DHCP Server Cmdlets in Windows PowerShell for more details.

$DHCPservers = ‘DHCP001’, ‘DHCP002’ $Scope = ‘10.80.24.0’ $IPaddress = ‘10.80.24.12’ $Server = ‘SQL001’ $Domain = ‘internal.vStrong.info’ $VM = Get-VM $Server # $VM.NetworkAdapters.MacAddress returns MAC address in semicolon separated 00:50:56:00:00:00 […]

VMware PowerCLI script to list Thin provisioned virtual disks (VMDK)

One of my clients was concerned about the number of virtual machines that were built with Thin provisioned disks. Before they go with the project to inflate all Thin provisioned disks (or migrate to Thick Provisioned Lazy Zeroed) they needed to know how much additional storage they would need.

PowerCLI to the rescue!

Yes, you […]

Exporting Virtual Machine information with PowerCLI

Just a quick script to export virtual machine inventory:

$report = @() foreach ($DC in Get-Datacenter -Name MyDC){ # Specify Datacenter name if needed foreach ($Cluster in Get-Cluster -Location $DC ){ # Specify Cluster name if needed foreach ($VM in Get-VM -Location $Cluster ){ $row = "" | select DC, Cluster, ResourcePool, VMPath, VMhost, PowerState, […]

VMware PowerCLI script to query Virtual Machine events

I have been asked to write a script to find out who created a particular VM or get a list of VMs that were built in the last N days…

Again, we need to go through the vCenter database and search for a particular event type or name. Cmdlet that is going to help us […]

HOW TO: Identify VMFS Datastore on Perennially Reserved LUN

We all well familiar with the problem with Raw Device Mapped (RDM) LUNs that are used by VMs running Microsoft Clusters Service.

VMware KB: 1016106

ESXi 5.0 uses a technique to determine if Raw Device Mapped (RDM) LUNs are used for MSCS cluster devices, by introducing a configuration flag to mark each device as “perennially […]

Who created these VM snapshots???

I am sure you have been in a situation where there are a lot of old, unidentifiable virtual machine snapshots and no one takes responsibility for creating them. How would you deal with all these “pre install”, “upgrade” or any other meaningless snapshot names without description?

Well, it is easy to find out when snapshot […]

HOW TO: Create custom vSphere ESXi ISO with VMware vSphere ESXi Image Builder

In this tutorial I will be building a custom VMware ISO image that includes VMware vSphere 5.0 Update 2, EMC PowerPath 5.7 P02, Cisco Nexus 1000v VEM and Cisco UCS M81KR VIC fnic and enic drivers.

Download all modules you are planning to add to the image and store them in a folder; You can […]

VMware PowerCLI and ESXi Shell scripts

Small collection of VMware PowerCLI / Powershell scripts and onliners to save time re-typing them:

Get a list of all virtual machines with snapshots and save it to a csv file; # Get-VM | Get-Snapshot | Select-Object VM, Name, SizeMB, Created, Description | Export-Csv c:snapshots.csv # Get a list of virtual machines, guest IP address, […]

HOW TO: Start, Stop, Restart services on VMware vSphere ESX server via PowerCLI

The service you will need to start or stop simultaneously on multiple servers is likely to be the SSH (TSM-SSH) service.

Here is how you do it with PowerShell / PowerCLI:

$vCenter = ‘vCenter.vstrong.info’ ; Name or IP address of your vCenter Server $Cluster = ‘Vblock cluster 1’; Name of the cluster Connect-VIServer $vCenter $Scope […]