vmxnet3 Ethernet Adapter #2 #3 #4

So what to do when you add a vmnic vmxnet3 to vm and it results in having a network adapter with vmxnet3 Ethernet Adpater #2 or #3 for example. Well i tried many different workarounds, solutions but for some reasons they were not working for me. I visited around 10-20 different pages with ms,vmware kb and still it was not working.  For some reason my network cards were not on the list even if i used ms kb to see hidden devices as described here:


How did i do it ? 🙂

First of all, let’s grab some knowledge about devcon.


Download devcon tool. Make sure you use the right version on the system. If you are running for example w2k8r2 64bit you will not be able to remove hidden device. You will be able to list it though using

devcon.exe findall =net

It will show you hidden devices, but when you will try to remove it using 32bit devcon.exe nothing will happen 😉

I could not find standalone version of devcon.exe so i had to download the whole tools iso file from Microsoft.

http://www.microsoft.com/download/en/details.aspx?id=11800 => Windows Driver Kit

Open the iso file image and look for



Copy those 2 files to some test folder like c:\test1

Then extract the msi package ( some info about msi http://msdn.microsoft.com/en-us/library/windows/desktop/cc185688%28v=vs.85%29.aspx )

cd c:\test1

msiexec /a setuptools_x64fre.msi TARGETDIR=”C:\sth\x\y”

And grab fresh 64bit devcon from


Copy the devcon.exe to the vm. If vm does not have any network use powercli for example.

Copy-VMGuestFile –LocalToGuest –Source C:\sth\x\y\winddk\7600.16385.win7_wdk.100208-1538\tools\devcon\amd64\devcon.exe –Destination c:\ -VM yourVM_NAME -GuestUser Administrator -GuestPassword “admin_password”

When connected to esxhost i believe you will have to use -HostUser <host user> -HostPassword <host password>  as well. I was doing this copy connected to vc via powercli.

Now run devcon.exe findall =net  if will print you the list with all network devices. In my case i found 2 which were not used and were causing the #2 #3 .

You will have to remove them all with: devcon.exe remove “@Your_unused_vmxnet_Device” , just copy/paste what’s on the left after executing devcon.exe findall =net regarding your vmxnet adapter.

Then repeat this step until will delete all of them. Reboot.

Now add the vmxnet3 adapter and see what happens 😉 Fresh clean nice and fluffy “vmxnet3 Ethernet Adapter” 🙂

By the way… If you want to have a template from which you will have a vm with clean vmxnet network adapter, then on the template make sure you have cleaned adapters using devcon, make sure that there are no vmnics added to that template vm. Shutdown the template vm. Then add a vmxnet3 network card. Save the vm as a template, and you can deploy vms from it. After vm will be deployed it will have a vmxnet3 network adapter without the #2 or #3 😉

I hope that this will save you a lot of time 😉

Check vm vmnic vlan

I wanted to get a list of vms that are using specific vlan so i wrote this one:

foreach($vm in (get-vm)){
if (Get-NetworkAdapter -vm $vm.name |?{$_.NetworkName -eq "network23" -or $_.NetworkName -eq "network65"}){$vm.name}

Ok, that was working but it was VERY VERY VERY VERY VERY slow…

So i wrote it using get-view :

$vms=get-view -viewtype virtualmachine
foreach($vmview in $vms )
$ntwkview=get-view -id $vmview.network
foreach($ntwkentry in $ntwkview){
if ($ntwkentry.name -eq "network23" -or $ntwkentry.name -eq "network65")

This one needed only 3 minutes to complete on a ~1000vm infrastructure. I stop the first script after 30minutes of running as it would probably finish next day …

The script is not perfect… yet 😉 but it will do the job and what’s most important quickly. I hope this will save you some time on reporting.

ESXi filesystem disk usage script

So what if you would like to get a report on filesystem disk usage on esxi box. For now afaik there is no cmdlet in powercli that could do that for us. So in order to get this data you can use plink to invoke command remotely via ssh

Frist, download plink.exe from putty website.

In this example i put plink.exe on c:\ drive

$str1=’c:\plink.exe -v -pw ”v53HYfsd#$%$%^^&*” -l root ‘
$str2=’ df -h’
“Host Size Used Avail Use Mounted” >> $outfile
foreach($esxentry in (Get-VMHost|?{$_.Powerstate -eq “PoweredOn”})){
$esxentry.name >> $outfile
$result=Invoke-Expression -Command $command
foreach($resultline in 1..$result.length){
$result[$resultline] >> $outfile

So, assuming you will have plink on c:\ and you will be in powercli session while connected to VC server, you can just copy/paste those lines and you will receive csv ready file in $outfile location. After this go to excel and do Data->import from text-> Select “space” as delimeter, and you are don. After that you can also select the USE column, and do conditional formatting for example.

If you want to make report for specific hosts that are in some DC folder, use the -Location switch in this line

foreach($esxentry in (Get-VMHost -Location “specific DC”|?{$_.Powerstate -eq “PoweredOn”})){

Script will only print information for hosts that are powered and and that are not in maintenance mode. You can use this solution also in different ways. Change the $str2 variable to whatever command you feel like and you can format the output to adjust it to new command. in $str1 you can give password with $ sign for example as well. In the last foreach loop i am not taking the first line [0] because it is the header which i have included in the beginning so there and the csv file is more readable because of this.  This is great base for everybody, modify it as you want and have fun 😉

PS.  If you have established the connection to esxi hosts before you can give to plink option -batch, if not don’t use it, and you will be ask the question about ssh key fingerprint

I will also write other version of this script, that covers a case where you don’t use plain password in -pw,  but ssh keys. If you know better way of getting the filesystem disk usage leave a comment!

Copy-VMGuestFile error While performing operation ‘Connect to host service ‘https://vc01/sdk’ at port 902′ the following error occured: ‘Failed to resolve host’

Copy-VMGuestFile : 4/11/2012 1:15:54 PM    Copy-VMGuestFile        While performing operation ‘Connect to host service
https://xyz/sdk&#8217; at port 902′ the following error occured: ‘Failed to resolve host’
At line:1 char:17
+ Copy-VMGuestFile <<<<  -LocalToGuest -Source C:\file1.txt -Destination c:\ -VM vmtest01 -GuestUser Administrator -GuestPassword “password”
+ CategoryInfo          : OperationStopped: (:) [Copy-VMGuestFile], VimException
+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_VixWaitForJob_VixError,VMware.VimAutomation.ViCore.Cmdlets.C

I got that error while trying to upload a file to a VM. I was connected to vc using it’s name vc01. When i have disconnected and connected again this time using FQDN vc01.mydomain.local it worked. So the reason while it was failing is because i was not connecting using FQDN of the VC server.

What is worth mentioning, in order to run cmdlets like copy-vmguestfile, make sure you are running powershell in 32bit, as it will not work under 64bit.