Posts tagged ‘storage vmotion’

Reader Request: Scripted VM Conversion to Thick from input CSV file using PowerShell PowerCLI

Written August 14th, 2013 by
Categories: Scripts, Virtualization
No Comments »

A few days ago I received a comment on This Post requesting a custom script to take a list of VMs from a file and convert them to thick. I quickly slapped something together and sent it to him for testing.

**REMEMBER** When converting thin to thick (or vice versa), you have to actually migrate the VM to a different datastore.

I’m posting this because it can be coupled with another post I have about Exporting VMs with Thin Disks to a CSV file, which would work perfectly for this. Run this one first to get a CSV with all your thin provisioned VMs.

In the Export Thin script, you will need to change the VM header in the CSV file to Name, since that’s what the migrate script looks for (or change the migrate script, up to you), add in a Destination header for the destination datastore in the CSV file after it’s exported. You could then plan it all out so your VMs are moved to specific datastores. Read the rest of this entry »

PowerCLI one liner to move all VMs on one datastore to another and convert to thick or thin

Written June 13th, 2012 by
Categories: Scripts, Virtualization

I wrote this post a while back on how to use the API to convert VMs from thin to thick, which you could also go from thick to thin using it. I had written it because I was trying to use the inflate function, which isn’t allow against powered on VMs.

It was pointed out by a reader that I could have simply used Move-VM to accomplish the same task. This is great, shows how a second set of eyes and a different perspective can help you solve the problem. You could simply do

Move-VM vmservername -Datastore datastorename -DiskStorageFormat thick

and it will move your VM to the specified datastore and convert to thick. You could use either thin or thick.

If you wanted to move every VM on a datastore, say Datastore1, to a new datastore, say Datastore2, and convert all of them to either thin or thick, you could do it like this:

Get-VM -Datastore Datastore1 | Move-VM -Datastore Datastore2 -DiskStorageFormat thick

You cannot specify the current datastore as the destination datastore, though. It will complete, but it will not convert your VM’s disk format, you have to actually Storage vMotion the VM to a different datastore. It basically validates the destination datastore is where it currently resides and exits without trying to convert your vmdk.

You could then take it a step farther and make a function that supports parameters, like if you wanted to move VMs on multiple datastores, or a given list of VMs to a specific datastore. For instance, you could create something like “convert-vms.ps1” and run it like this

convert-vms.ps1 -vms ("vm1",vm2","vm3","vm4") -destination datastore2 -thick

and it would move all four VMs to datastore2 and convert them to thick in the process. Or something like

convert-vms.ps1 -source ("datastore1","datastore2") -destination datastore3 -thin

That would move all VMs from datastores 1 & 2 and thin provision them on datastore3.

If anyone’s interested in the actual script/function, let me know and I can put one together fairly quickly.

Function to convert VMs from thin to thick using #PowerCLI & #PowerShell

Written March 20th, 2012 by
Categories: Scripts, Virtualization

Most people want to go from thick to thin to save space. I, on the other hand, want to convert my VMs from thin to thick. Thin provisioning buys you time, basically, but what do you do when you’re vastly over provisioned and your VMs are filling up available physical storage? Sure, you can manually go to each VM and use the GUI to migrate them and convert each one to thick. I had a couple hundred that were thin provisioned and needed them converted to thick.

I’ve been moving from 500GB LUNs to 1TB LUNs, so I scripted it out to migrate VMs over, as well as convert to thick using the New-Object cmdlet.

Read the rest of this entry »

Mass Storage Migrations using vSphere Storage vMotion and PowerCLI

We ran into an issue where we needed an entire SAN frame retired. Problem is, there are several datastores and several guests running on that frame.

I wanted to script it out, which worked just fine. Then, we had more to do, so I edited the script and ran it again. After the third or fourth time, I decided to write a script that takes params via the cli.

Make sure your datastore names are similar, for instance, mine appends ‘_New’ to the end. So my datastores have to be named like this: ‘vmdatastore’ and ‘vmdatastore_New’. It will get all guests on the datastore and migrate them one by one over to the new datastore. When done, just delete the old datastore (or rename it to _Old) and rename the new one to match.

My script: Read the rest of this entry »

Designed by ThepHuck
Wordpress Themes
Scroll to Top