Ratio of Physical CPUs to Virtual CPUs in VMware

Posted by robd on August 06, 2018
powershell, vmware / 1 Comment

My colleague Welsh Dai made this sweet bit of PowerShell to see the ratio of physical CPUs to Virtual CPUs:

$allhosts = @()
$cluser2hosts = Get-VMHost | where {$_.Parent -LIKE "ClusterName"} 
foreach ($vmhost in $cluser2hosts)
   $vms = $vmhost | Get-VM | select name,numcpu | measure -Property numcpu -Sum
   $hostload = New-Object psobject -Property @{
            hostname = $vmhost.Name
            PhysicalCPUs = $vmhost.NumCpu
            vCPUs = $vms.Sum
            hostratio = $vms.sum / $vmhost.NumCpu
    $allhosts += $hostload 

$allhosts  | select hostname,physicalCPUs,vCPUs,hostratio | sort hostratio


Here’s a picture

Tags: , , ,

Find WWN for a Converged network Adapeter via PowerCLI

Posted by robd on October 26, 2016
Encyrption / No Comments

As per the title:

# All hosts connected in vCenter
$scope = Get-VMHost     
#OR specify a cluster
#$scope = Get-Cluster -Name 'Vsphere.Cluster01' | Get-VMHost

foreach ($esx in $scope){
Write-Host "HostName:", $esx
$hbas = Get-VMHostHba -VMHost $esx -Type FibreChannel
foreach ($hba in $hbas){
$wwpn = "{0:x}" -f $hba.PortWorldWideName
Write-Host `t $hba.Device, "|", $hba.model, "|", "World Wide Port Name:" $wwpn

Tags: , , ,

VMDK size limit for creating a snapshot

Posted by robd on April 09, 2016
ESX / No Comments

Came across this today, if you have a VMDK file that is over 1.98TB you will not be able to create a snapshot of the server. Please see articles below.

Essentially you need to allow for a 16GB overhead so the maximum size the VMDK can be is 2032GB, 1.99TB calculates to 2037GB and 1.98TB calculates to 2027GB.

Tags: , , ,

Veeam Updated

Posted by robd on February 07, 2013
Veeam / No Comments

Recently we had some major system changed!!

We built a new VMware vCenter Server and upgraded all our ESX hosts to 5.1 then shifted all our VM’s to the new vCenter!

All was good in the world….until the witching hour and the Veeam backups kicked in!!


FAIL!  Massive Fail!!


Ok so my fault, Veeam can’t see the new vCentre…so I added it to the vCenter and made sure Veeam could see the VMs!  Gave it a try and they still failed with:


Task failed Error: Object SERVER not found.


Why, you ask…well the hosts have the same name but are also different due to the upgrade and the new vCenter so Veeam can work out how to route to the VM and most probably it’s going to try and route to the old host which technically doesn’t exist (on that vCenter)!!


So we need to edit the SQL Database and delete the duplicate host entries!


Here’s how:


--Find the duplicates
 SELECT name, count(name) as _dupes from [Hosts]
where type in (0,6)
group by name
having count(name) > 1
order by _dupes desc



-- Delete the duplicates where they match the old parent id of your old vCentre.
delete from [hosts]
where name = 'Host1.domain.local' and parent_id != '3242B2CC-022B-42C8-8AB2-BB77B2F2B5F2' or
name = 'Host2.domain.local' and parent_id != '3242B2CC-022B-42C8-8AB2-BB77B2F2B5F2'



Gave it another run and the backups worked!!

Tags: , ,

When Exchange 2010 Breaks

Posted by robd on January 11, 2013
ESX, exchange 2010, powershell, WAN / No Comments

Part 1

So recently a client had some WAN issues where the WAN kept dropping packets on the primary link, meaning some network traffic would work fine and other network traffic would fall off the face of the planet!!


Unfortunately the system affected the most was Exchange 2010!!  The site had Exchange 2010 DAG set-up between two sites.  One on Site A and another on another site B with the File share witness on Site A.  So because some traffic was flowing nicely and some wasn’t some of the cluster services were up and some went down meaning the DAG got in a pickle!


Site B ended up taking ownership of the DAG and wouldn’t let go because he file share witness wasn’t available.  So as people could still get mail, I patiently waited for the WAN to be fixed (in the end someone pulled the primary link which forced the secondary to take over and everything became hunky dory).


So now the WAN was back and happy but still the cluster service wouldn’t appear, so after digging the arp entries were missing (no idea why), so ended up creating another IP for the cluster service….Done.  It’s up, time to reseed!


Update: Well shit me, MS know about this:


Well anyway I wish the reseed was that easy! During the issues, the mail store was un-mounted and now it won’t mount!! Booo, so another admin decided to run eseutil and recover the DB which worked but then decided to seed the wrong way meaning site B now has an old mail store with no mail from that day!!  BUGGER!


Part 2


So I need to rerun all the mail and then import and luckily all the missing mail logs are still on Site B!

I know what you’re thinking:


Restore the EDM file from a backup,

Rerun the Logs via ESEUTIL,

Mount the recovery DB,

Merge users,



Well the business was very panicky now and didn’t want anyone touching anything on Exchange till things settled down, fair enough a day’s worth of mail is missing at the moment so people are touchy.


So I decide to make use of the most excellent Veeam feature SureBackup, which will allow me to restore the entire exchange live setup including a DC in lab environment without touching the live environment!!  Brilliant!


So I set it up, add a host, some storage, make sure I have a good backup of Exchange and it runs, great!!  Be careful though as it uses snap shots heavily so every change adds to a delta file meaning storage gets eaten!!  So here I am with the live environment in a lab environment, there some issues as I cant restore site B, so I have to remove the DAG and the other site which I do via ADSI edit (quick and easy but dangerous)!


So I copy over the recovered DB I restored with file level restore on veeam (copied by creating a HD in ESX and mounting it on veeam and copying file to it then mounting in my lab),

Create a recovery DB:

new-mailboxdatabase –recovery –name databasename –server servername –edbfilepath pathtodatabase –logfolderpath pathtologfile


Checked the logs:

Eseutil /ml “d:\logs\E00”



Eseutil /r E00 /d d:DB /l “d:\LOGS” /i /s “d:\LOGS”


(May of run ESEUTIL /p too, cant remember)




Emails are all there but in the disconnected items section, reconnect to a test db and GREAT the emails are there!!


So connect all the mailboxes (manually unfortunately), then export them to pst (to my mounted HD):

New-MailboxExportRequest -ContentFilter {((Received -le '12/12/2012') -and (Received -ge '01/12/2012')) -or ((Sent -le '12/12/2012') -and (Sent -ge '01/12/2012'))} -Mailbox “User1” -Name MailboxNameExp -FilePath \\Server\psts\User1.pst


Un-mounted the HD, added the HD to the live environment and imported the PSTS:

Dir \\Server\psts\*.pst | %{ New-MailboxImportRequest -Name BulkPSTImport -BatchName Recovered -BadItemLimit 250 -AcceptLargeDataLoss -Mailbox $_.BaseName -FilePath $_.FullName} >C:\Scripts\resultsBulkCalendar.txt 2>&1

Tags: , , , , ,

ESX Gateway Host entry

Posted by robd on August 08, 2012
ESX, vSphere / No Comments

Had an annoying error today while trying to add a ESX 4.1 host to DataCenter:

Call “datacenter.queryconnectioninfo” for object “DC or Cluster Name” on vCenter Server “vCenter” failed.

Firstly I thought my password may be wrong for the host, it wasn’t!

Then, maybe my new host is in maintenance mode, it wasn’t!

Finally, and really it should of been obvious to me:

I’d changed the IP address twice while building the box via the console and had forgotten to enter a new default gateway!

So jumped on vSphere for the new host,
clicked the Configuration tab,
clicked Networking,
clicked properties (the one next to Virtual Switch: vSwitch0),
click Service Console and edit,
click Continue modifying this connection..,
clicked IP settings and
Added a Service Console Default Gateway! OK’d out

And Bam, added the host to the Datacenter!!

Tags: , , ,