Using PowerShell to provision Nimble Zero Copy Clone to ESXi server

Discussion created by wen Employee on Jan 15, 2014
Latest reply on Feb 3, 2014 by Justin Rich

Here's a quick & dirty script to perform the following task:

  • create zero copy clone of VMFS volume
  • provision clone to ESXi host follow by rescan
  • write new signature + rename VMFS volume
  • register every VM in the new clone in ESXi host




-plink should be downloaded & installed in the appropriate directory; my example is using plink executable in c:\secloud folder

-script could use some TLC in terms of error checks and prompt for user input; when time permits, I will enhance it; of course, you are welcome to modify/add to source and contribute back, isn't that the whole point of a kick-*** community like nimble connect?



In PowerCLI, simply execute the script with the source code below


In PowerShell, run the following commands prior to execution of the script:

add-PSSnapin VMware.VimAutomation.Core

Set-ExecutionPolicy unrestricted -confirm:$false -force


Source code:

#get array to clone the base vol





$name='What name do you want for the clone?'



$plinkarrayoptions="$array -l $user -pw $pw"

$remotecmd1="vol --clone sourcevolname --snapname nameofsnapshottoclone --clonename"

$command=$plink+" "+$plinkarrayoptions+" "+$remotecmd1+" "+$name+" --initiatorgrp esx55hulk"



$msg=Invoke-Expression -command $command




#VMW side task

connect-VIServer -Server -User root -Password pass

$esxhost = ''


#get new clone provisioned to ESX host

$esxcli = Get-EsxCli -VMhost $esxhost -ErrorAction Stop

Get-VMHost | Get-VMHostStorage -RescanAllHba



$snap=$esxcli.storage.vmfs.snapshot.list($null, $null)

$snapobject= $snap | select-object -property VMFSUUID


$esxcli.storage.vmfs.snapshot.resignature($null, $uuid)

sleep 100

get-datastore | where {$_.Name -match "snap"} | Set-Datastore -Name $name



new-folder $name -Location parentfoldername



#register all VMs in the datastore

dir "vmstores:\\SJNimbleTM\$name\*\*.vmx" | % {New-VM -VMHost $esxhost -VMFilePath $_.DatastoreFullPath -Location $name}