, , ,

Move multiple disks from one vm to another vm (KB#00102)

Hello Folks,

Adding another solution for one unique challenge I got from my customer. 

Challenge - Customer used to move multiple vmdk files from one vm to another vm in vcenter server. Actual challenge is the time in hand for this operation and number of vmdks to remove are always around 15, 18 or 20 per vm. This activity used to have multiple VMs. This become more challenging at the time of roll back once we have moved all disks from source to target vm. That much of vmdks to move and in short period of time can lead to confusion and human error too.

Solution - I created below powercli script which drastically decrease the time require in such activity and roll back too become very easy with it. Chance of human error is 99% lesser now.

Below is the code -

Function move-vmdk{
= Get-Date
#It will record the timestamp before starting this activity

"Current time is $time"
= Read-Host "Enter the source VM Name "
"Total number of disk on source vm is" (Get-HardDisk -VM $sourcevm).count -ForegroundColor yellow
= Get-HardDisk -VM $sourcevm
= Read-Host "Enter the target VM Name "
"Total number of disk on target vm is" (Get-HardDisk -VM $TargetVM).count -ForegroundColor Green
"This script works with file name of disk to move so please mention the filename of each disk to move in notepad and save it in C:\temp with disklock.txt name"
#save the disk’s location for all the targeted disks to path C:\Temp in notepad file named diskloc.txt
= Get-Content -Path C:\Temp\diskloc.txt
= Read-Host -Prompt "Are you sure you want to process for this disk migration (Y/N) "
($confirm -eq "y") {
($loc in $diskfile){
= Get-VM -Name $TargetVM
=get-vm -name $SourceVM | Get-HardDisk | Where-Object {($_.Filename -eq $loc)}
$disk -Confirm:$false
-VM $trgVM -DiskPath $loc
(" ")
= Get-Date
#It will record the timestamp after completion of this activity
"Operation has been completed succesfully"
"Current time is $time"
"Total number of disk on target vm is" (Get-HardDisk -VM $TargetVM).count -ForegroundColor Green
"Total number of disk on source vm is" (Get-HardDisk -VM $sourcevm).count -ForegroundColor yellow

Below is the sample output

Note that time taken is just 32 seconds to move four VMDK files. Just to add, size of vmdk doesn't change the time for this migration.

Hope you will find it useful if you too have such requirement! Any doubt or thought, plesae feel free to comment.



, ,

Delete an object in VMware Usage Meter (KB#00101)

Hello Guys,

If you ever got stuck with any issue with VMware Usage Meter then you might know that there are not enough troubleshooting KBs from VMware or enough troubleshooting articles on it. I too got stuck in one issue and couldn't find any article which could help me. I raised a SR too but it was pending since weeks without any support from VMware Support team. 

I continued to work on it and finally could resolve it by my own hence thought to create a KB here on vcnotes.in.

Issue : Duplicate entry found of same vcenter server through two different vROPS instances. Now need to delete vROPS server from usage meter from product page (Usage Meter Version 4.4). In my case, I didn't want three vROPS entry here and want to delete one which is bringing in the duplicate vcenter entry. This KB will help you to understand how to delete any product from product list in usage meter.

Roadblock : There is no option to delete the vROPS product in version 4.4's GUI. Please note that this version comes with HTML5 interface. In flex interface you could do it but in HTML5, there is no such option for vROPS. Reason is, Usage meter pick vROPS from vCenter MOB extension. I was having below kind of state. I had to change the snippet with vcenter name.

You can see that in vRealize operation page there is a vcenter named vcenter2.vcnotes.in is showing against two different vrops nodes that are and 

This is a mess and we need to clean this up. I want to delete the entry against but there is no option to delete. 

Solution : Solution is to use API.

1. Connect Usage Meter in API tool as explained below

Query -

Header -

Credentials -

Once you entered the filed as above, hit the send button, it will give you output like below

Note that in above snippet you have message "202 Accepted", means you are logged in now. Also, you have sessionid in Body. It will be used as a header for further work. Let's check further.

Now, the requirement is to delete the product. Use below delete query-



api call is -

id - this is the prdouct ID, well visible in the HTML5 web page when you login in usage meter

product tye - it is to mention that the product you are trying to delete is vcenter, vcd, vrops or something else

forget - it is to delete the history and for full cleanup. You should always use it.

Headers will be - 

Accept : Application/json (used earlier)
session id : extracted after login in above steps

Once you have given all the required parameters, hit the send button and targeted product will be delete from VMware Usage meter UI page.

Now when you read above stuff, you should be able to understand this VMware documentation for more information on API operations with VMware usage Meter. 

Thank you.