Moving-VMThin thin (Thick Powercli to svMotion) feature

Hello world

I got this LucD fuction in another post on the forum and changed it to try to convert a large number of virtual machines to thickness thin disks.  I seem to be getting an error on the first virtual machine each time and the second seem to work very well.  If someone could tell what I did wrong, I would be happy.

Error:

You can not call a method on a null value expression.
C:\Users\xxx\Documents\xxx.ps1:33 char: 31
+ $vmView.RelocateVM < < < < ($spec, $null)
+ CategoryInfo: InvalidOperation: (RelocateVM:String)], RuntimeException
+ FullyQualifiedErrorId: InvokeMethodOnNull

Script:

$vmarray = @("TestVM1","TestVM2")
$datastore = get-Datastore. Sort FreeSpaceMB descending
function {Move-VMThin
(PARAM
[Parameter (mandatory is $true, ValueFromPipeline is $true, HelpMessage = "Objects of Virtual Machine migration")]
[ValidateNotNullOrEmpty()]
[System.String] $VM
, [Parameter (mandatory = $true, HelpMessage = "Destination data store")]
[ValidateNotNullOrEmpty()]
[System.String] $Datastore
)

Begin {}
Necessary to treat #Nothing the
} #Begin

{In process
#Prepare migration info, use the .NET API to specify a transformation to thin disk
$vmView = get-View - ViewType VirtualMachine-filter @{"Name" = "$VM"}
$dsView = get-View-filter-Datastore-ViewType @{"Name" = "$Datastore"}

#Abort migration if the free space on the destination data store is less than 50 GB
If (($dsView.info.freespace/1Go) - lt 50) {throw "Move-ThinVM ERROR: data store of Destination less than 50 GB of free space $Datastore."} This script requires at least 50 GB of free space for safety. Please free up some space or use the VMWare Client to perform this Migration"}

#Prepare VM Specificatoin for moving
$spec = new-Object VMware.Vim.VirtualMachineRelocateSpec
$spec.datastore = $dsView.MoRef
$spec.transform = 'rare '.

#Perform migration
$vmView.RelocateVM ($spec, $null)
} #Process
}
for ($i = 0; $i - lt $vmarray.count; $i ++)
{
$datastore
$snapshot = get-VM-name $vmarray [$i] | Get-Snapshot
If ($snapshot - eq $null)
{
$vmds = get-VM-name $vmarray [$i] | Get-Datastore
If ($vmds - don't $datastore [0])
{
Moving-VMThin - VM $vmarray [$i] - Datastore $datastore [0]
}
If ($vmds - eq $datastore [0])
{
Moving-VMThin - VM $vmarray [$i] - Datastore $datastore [1]
}
}
If ($snapshot - no $null)
{
Write-Host [$i] $vmarray + "has a snapshot" - ForegroundColor Red
}
}

The mystery is solved, the actual name of the virtual machine contained some RegEx metacharacters.

When they escaped to the oblique, the Get-View filter worked without problem.

For example, the VM name contains parentheses, which are group of RegEx characters. This

$vmName = ' TestVM (1).

Notice-EEG - ViewType VirtualMachine-filter @{"Name" = $vmName}

won't do anything.

But

$vmName = 'TestVM\ (1\).

Notice-EEG - ViewType VirtualMachine-filter @{"Name" = $vmName}

will be.

Tips: Avoid the RegEx meta-characters in the name of your virtual machines.

Tags: VMware

Similar Questions

  • Convert a disk of thin thickness without interruption

    Can I convert all disks on a thin thickness virtual computer without turning off the virtual machine?

    Yes, if you have the Storage vMotion available in your environment... just migrate the virtual machine to a data to another store and select the disk of destination in. thick.

    Have a look here: http://www.mikelaverick.com/2014/04/back-to-basics-advanced-virtual-machine-administration/

  • How can we change the disc type of thin thickness of a virtual machine?

    Hello

    We use vSphere vCenter 5.0, 5.0. How can we change the disc type of thin thickness of a virtual machine?

    Kind regards

    ZaraRose.

    Storage vMotion, cold migration, vmkfstools and VMware Converter

  • Strange behavior of 'Thin-thick' when there is an active Snapsot

    Hi there all

    I just stumbled upon a VI client behavior that I can not explain at all.

    Scenario:

    1 VM is created with two drives (see screenshot1) thin provisioned

    2. next, we create a snapshot

    3 and all of a sudden customer VI shows that the disc are now thick commissioned, although when you browse the data store we can clearly see that they are thin (see screenshot2/3)

    Everyone came through everything?

    Information on the environment

    VCenter 4.1.0 build 345043

    ESXI 4.1.0 build 348481

    screenshot1.JPG

    screenshot2.JPG

    screenshot3.JPG

    Hello and welcome to the forums.

    This is the behavior expected and specified in KB 1020137.

    Good luck!

  • Confusion between display Navigator datastore, thin thickness vs, vs size put into service

    Hi all

    ESXi 4.1

    It's very confusing.

    The case is:

    A virtual machine is configured with 50 GB of HARD drive fine.

    (1) in the browser of data store, the display is:

    Size: 11 GB

    Provisioned size: 50GB

    (2) the size of the SSH vmdk file is 50 GB

    So my question:

    (1) what is the use of the real space of the virtual machine? 11GB or 50GB?

    In my understanding, since it is a provisioning, it should be 11FR. But why SSH it shows 50 GB?

    (2) why the VM with Vista, there no column 'provisioned size' in the browser data store?

    Thank you.

    If you use thin discs, the space used in your example is 11FR.

  • SVmotion - thick disk of source-&gt; svmotion-&gt; should become a thin disk in vSphere CLI power

    Hello

    I tried to perform a SVmotion using vSphere CLI power and it works fine.

    But when executing the SVmotion, I also want to mention the DISC FORMAT' i.e. ' thin... ". While the SVmotion I want the drive to be THIN DISK PROVIDED.

    Move-VM - VM (VM-Get-name litbuildvm) - Datastore & lt; name of store data & gt;

    Can someone help him, now in the above command, the source vmdk is THICK implemented after SVmotion remains thick.

    But I want to make the disk vmdk source which is THICK to THIN after SVmotion in vSphere CLI...

    Help, please

    Deepak

    Yes, that's correct.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Thin to thick 100 VM

    Hello world

    I have a situation where I need to convert about 400 + VM thin-thick discs put in service. Rather than carrying on my buttons of the mouse by using the GUI, I thought if there is a way for this script.

    I would like the script to do the following

    Name of lun hard-coding

    Locate the thin disks provisioned

    Prompt to convert - need to keep an eye on storage limits.

    Convert to thickness

    Is this possible to do with PowerCLI the performance of virtual machines without svMotion the VM?

    Thank you

    David

    The cmdlet Get - hard drive has different settings for models and virtual computers.

    So I'm afraid you don't their in 1 shot.

    Maybe add a 2nd loop for the models in this 2nd loop, you can copy the loop, simply change "Get-hard drive - VM... «to ' Get-disk hard-model...» »

  • Moving thin model w / Clones related

    We have 6 thin gold models put in service and have filled the data store that they are on. Long story how it happened. The process that is used is a user of Clones in the workspace using a linked clone and then deploys the machine from there.

    I need to spread thin between other data warehouses provisioned templates so that it does not happen in the future but I understand that if I use the action to consolidate to move one of these models, it will affect all the related clones. Is this correct?

    If so is there another way to move a thin model to a new data store and do not break the linked clones?

    The only other option is to make a copy\clone of the model and moving it, but the problem with that is that it converts the Thin Thick model as we use LM 4.0.2. So if I cloned the model and it converted to thickness is there a way to get Thin again?


    Then I could take these new thin models and spread them out and those that can be used as the 'old' is not deployed.

    Thanks for reading so far and suggestions.

    Option 1: Move an existing model and all the virtual machines:

    SSMove moving (cut and paste) a clone tied together tree between data warehouses.  However, I would like to you to be on Lab Manager 4.0.4 (final version), as it has a few minor improvements to the tool.

    You must also cancel the deployment of all the virtual machines that are related to this.

    Option 2: move the template only via a full consolidation.

    This movement of the model only.  The model gets consolidated to the new data store.  The new virtual machines configured from the model will go to the new data store where the vmdk.

    The previous VMs will always exist and work.  As they are removed, the space will be released on the previous drive.  If all the vmdk related to the orignial tree is removed, then the entire tree will be cleaned.

  • After Storage vMotion my VMDK is thin, even after the selection of thickness

    Hello

    I'm looking to convert the thick disks via svMotion.  I try to avoid interruptions of service on the virtual machine.  We have no space to achieve the svmotion in another data store.  So I thought that I move it to local storage on the host and then again to the NAS.

    I have svMotioned the virtual machine from a NAS device to the storage local to the host, verified size put into service and it was thick with success.

    So, I then tried to bring him back to the NAS and selected thickness, and as soon as it was over the disc was thin again.

    Why my storage vMotion finish and leave my discs to thin format?  Any ideas on what gives here?

    Sorry if this has been answered elsewhere, I searched and have not found a lot of thickness.  Does not appear that many use this format in good standing.  We are a large company and do not actively monitor the use of the disc - we use the thick option to avoid any downtime due to space problems.

    Thanks for any idea!

    The format of the virtual disk on a NAS storage is dictated by the NAS. Take a look at the configuration guide http://www.vmware.com/pdf/vsphere4/r40/vsp_40_esx_server_config.pdf (page 101)

    André

  • Can I convert a thin disk that is implemented in a thick disc put into service

    We run ESX4 Advanced Server as a standalone server.   No server VCenter.  The person who initially set up the server and the machine virtual used comments a provisioning and storage committed plu.  I have moved a few guests to another storage group and another host, but I would get all converted in thickness to avoid problems in the furture.  Is it possible to do with rebuilding the guest computers.

    Also how hard is it to resize the virtual disks and make them smaller.  For example, I have a few volumes of 50 GB using about 15 GB, I want to reduce to about 30 GB and recover the space.  Is this possible without having to reinstall the client o/s.

    Also if you know we do not use VMotion or VCenter.  Stand alone a few servers with local storage.

    Once again the quesiton so.  If I use the VMware Converter to change the thin provisioned in. thick, is it possible keep the virtual machine on the same host.  Whenever I used the converter, he sought a source and destination ESX server.  I do something wrong when I use it?

    Yes, when you use vConverter you can change thin thick (flat) also resize it. To use the same host, it is even not VM must appoint as before, you can put the same ESX host in source and destination. But then again, do not to use the same VM name. Good luck.

  • changing thin to thick

    How can I change a disc of thin thickness?

    If you have a vCenter and sVMotion license, you can change the disc format, but if you work with independent classic ESX 4.0, then you will need to do this manually using the vmkfstools or if you're on ESXi 4.0, you will need to use vmkfstools vCLI. I think that VMware Converter can also do it for you if you do not want to use the command line.

    =========================================================================

    William Lam

    VMware vExpert 2009

    Scripts for VMware ESX/ESXi and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

    Twitter: @lamw

    repository scripts vGhetto

    Introduction to the vMA (tips/tricks)

    Getting started with vSphere SDK for Perl

    VMware Code Central - Scripts/code samples for developers and administrators

    150 VMware developer

    If you find this information useful, please give points to "correct" or "useful".

  • Features of the line of my mouse and the pen tool are thicker than my tablet.

    Hello, I have just built a new computer and tried drawing in Photoshop but it turns out that my features of line of my mouse and the pen tool appear to be twice as thick as my Tablet features. I am currently using the Wacom Intuos small Pen & Touch tablet. I messed with the settings and put sensitivity to pressure for setting low to make sure that I get a fixed size for each shot, so it's probably a sensitivity problems. I don't have this problem with my last computer when I used the same Tablet and the program Photoshop I use now. Does anyone have suggestions about how can I fix? Thank you for your time.

    Occam's razor would tell us that it is almost certainly a problem with spring pressure.

    Or the other of the two first round brushes by selecting in the brush Panel must ensure pencil and mouse identical brush sizes.

    The other thing to look at is the options bar.  The other icon highlighted in red, is the pressure change opacity.

    You can use both at the same time.

  • Change from Thin to thick to help inflate the parameter-&gt; specified is not correct

    Hello

    I wan to convert a VM disk of thin thickness.

    When "inflate" a disk from the data store, I get the message "a specified parameter was not correct."

    What to do to fix this?

    THX

    Please make sure you have machine virtual shutdown and deleted all the snapshot before proceed you to inflate. After you blow up if you see "the disc is not thin-provisioned." This means already changed my thick and in order to see the thickness that you will need to relaod the file vmdk by removing and joining the drive

  • How to convert a thickness thin provision

    Hello

    I converted physical machine to virtual .during this process, I chose to files on the hard drive thick delivery.

    now I want to convert all files to provision thin to save storage.how can I convert thick to thin provision.

    I haven't used this link procedure Storage vMotion is much easier, and yes it free your place if you go thin thickness.

    This link may be also useful: http://www.thelowercasew.com/reclaiming-disk-space-with-storage-vmotion-and-thin-provisioning

  • Storage vMotion with zero eager thick

    Hello

    In version 5.0, with the GUI, when you want to svmotion a virtual computer, you have three choices for storage: zero lazy thin / thick / thick zero eager.

    We have a lot of virtual machine in lazy mode thin / thick and want to convert it to thick eager without interruption of service.

    In Powershell, smovtion is ' Move-VM cmdlet. It has the possibility of "DatastoreStorageFormat" who don't accept that end/thick for the parameters (from the documentation).

    After a few tries, moving a VM thin with the cmdlet and "thick" in setting create a vmdk in "zero lazy thick."

    Some try with "EagerZeroVirtualDisk_Task" of the API too, but a problem with a lock on the file. It is not really clear in the documentation, but I think that the virtual machine must be poweredoff in order to use this feature.

    Is there a way to powercli to a storage vMotion and (re) create vmdk zeroing eager mode thick?

    Try it like this

    $vm = Get-VM -Name MyVM $destinationds = Get-Datastore -Name MyTargetDS $HardDisks = @(Get-HardDisk -VM $vm)
    
    $spec = New-Object VMware.Vim.VirtualMachineRelocateSpec $spec.Datastore = $destinationds.Extensiondata.MoRef
    
    1..$HardDisks.Count | %{
        $newFilename = "[" + $destinationds.Name + "]" + ($HardDisks[$_ -1].Filename.Split(']')[1])
    
        $objBackinginfo = New-Object VMWARE.Vim.VirtualDiskFlatVer2BackingInfo    $objBackinginfo.DiskMode = "persistent"    $objBackinginfo.eagerlyScrub = $true    $objBackinginfo.FileName = $newFilename
        $objDisk = New-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator    $objDisk.DiskID = $HardDisks[$_ - 1].Id.Split('/')[1]
        $objDisk.DataStore = $destinationds.Extensiondata.MoRef    $objDisk.diskBackingInfo = $objBackinginfo
        $spec.Disk += $objDisk
    }
    $vm.ExtensionData.RelocateVM_Task($spec, "defaultPriority")
    

Maybe you are looking for

  • iPhone 4 continues the search for carrier

    Recently, I set my iPhone 4. And the iPhone keeps searching for service or signal or what they called it. I tried just like update my carrier setting, reset the network settings, turn on and outside airplane mode and even restore the phone. The most

  • Windows 7 black screen with the cursor of the mouse in normal mode and safe

    Hi allI hope someone can help.Laptop downloaded updates and after the restart will only go to a black screen with the mobile mouse cursor.This occurs in safe mode, normal mode.I tried all variations of safe mode and still the same thing happens.Last

  • I have the Trojan.DOS/Alureon.A.

    I want to delete it by using the command.  However, I don't know how to use this tool.  For example can I use > bootrec/exe too. Need to know exactly how to type the information in the command.  Thank you!

  • can error code 8e5e03fe-how I fix it?

    error code 8e5e03fe, how do I fix?

  • G16 format not supported in lightroom 4?

    HelloI have lightroom 4 and I'm on a Mac.  I have not upgraded because 4 generally meets my needs - perhaps so far?Recently I tried to put in RAW format from a Canon G16.  Not a new camera and adobe says support LR supports the camera (but don't say