<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article vSphere Linked Clone script in Italian Documents</title>
    <link>https://communities.vmware.com/t5/Italian-Documents/vSphere-Linked-Clone-script/ta-p/2775550</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I LinkedClone, così come siamo abituati ad utilizzarli in Horizon View, non sono disponibili in un ambiente "solo" vSphere ma può capitare di voler gestire degli albienti applicativi come LinkedClone di una sistema "master". Già da tempo è disponibile una procedura, ovviamente ufficiosa, per la creazione di LinkedClone su vSphere ma eseguire i passi a mano può comportare un eccessivo dispendio di tempo oltre ad incappare in banali errori.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://rsiciliablog.wordpress.com/2016/03/06/vsphere-linkedclone-script/"&gt;In questo post ho riportato e spiegato una script per automatizzare un po' la procedura&lt;/A&gt; in questione e di seguito ne illustro i passaggi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Premessa: la VM indentificata come master deve essere stata configurata secondo le proprie esigenze, spenta e, una volta completato lo shutdown, è necessario eseguire una snapshot (nome a piacere).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Per prima cosa ci connettiamo al vCenter e definiamo un po’ di variabili, in particolare il nome della VM master, il path dove troviamo i files a livello ESXi/Datastore, la directory di lavoro temporanea ed il nome della VM clone che creeremo:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Add-PSSnapin VMware.VimAutomation.Core | Out-Null&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Connessione verso vCenter Server..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Connect-VIServer -Server &lt;EM&gt;10.0.0.1&lt;/EM&gt; -User &lt;EM&gt;administrator@vsphere.local&lt;/EM&gt; -Password &lt;EM&gt;pwd&lt;/EM&gt; -WarningAction SilentlyContinue&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo ""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$vmname = "VM-MASTER"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$path = "/vmfs/volumes/&lt;EM&gt;xxxxxxxx-yyyyyyyy-zzzz-wwwwwwwwwwww&lt;/EM&gt;/$vmname/"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$tempDir = "c:\LINKED-CLONE"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$cloneName = "VM-CLONE1"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Successivamente identifichiamo la VM e definiamo un “mount point” per il Datastore che la ospita così da scaricare i files che ci interessano:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$master = Get-VM -Name $vmname&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Procedura di gestione LINKED-CLONE per la guest $vmname"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$datastore = Get-Datastore "&lt;EM&gt;DS-LOCAL&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;New-PSDrive -Location $datastore -Name ds -PSProvider VimDatastore -Root "" | out-null&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Download VMX file..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Copy-DatastoreItem "ds:\$vmname\*.vmx" "$tempDir\$cloneName.vmx"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Download SNAP file..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Copy-DatastoreItem "ds:\$vmname\*-000001.vmdk" "$tempDir\"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Download DELTA file..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Copy-DatastoreItem "ds:\$vmname\*-000001-delta.vmdk" "$tempDir\"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I file scaricati sono la base per la nuova VM e vanno opportunamente modificati. Si tratta di cambiare pochi parametri quindi torna comoda la PowerShell:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Edit VMX file"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$vmx = Get-content –path "$tempDir\$cloneName.vmx"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$vmx_new = $vmx -replace "displayName = ""$vmname""", "displayName = ""$cloneName"""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Set-content "$tempDir\$cloneName.vmx" $vmx_new&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Verifica file name per $master"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$file = Get-ChildItem -path $tempDir -Filter *-000001.vmdk&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$filename = $file.Name&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Identificato file $filename"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Edit SNAP file"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$vmdk = Get-content –path "$tempDir\$filename"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$vmdk_new = $vmdk -replace "parentFileNameHint=""", "parentFileNameHint=""$path"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Set-content "$tempDir\$filename" $vmdk_new&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Infine i files vengono caricati nel Datastore e la nuova VM aggiunta all’inventory:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Upload..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;New-Item -Path "ds:\$cloneName\" -ItemType Directory | out-null&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Copy-DatastoreItem "$tempDir\$cloneName.vmx" "ds:\$cloneName\"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Copy-DatastoreItem "$tempDir\*-000001.vmdk" "ds:\$cloneName\"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Copy-DatastoreItem "$tempDir\*-000001-delta.vmdk" "ds:\$cloneName\"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Inventory nuova VM..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;New-VM -VMFilePath "[DS-LOCAL] $cloneName/$cloneName.vmx" -ResourcePool "MyPool"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Done!"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;La nuova VM utilizzerà, in sola lettura, il file VMDK della VM master e scriverà le proprie modifiche nei delta disk posizionati nella propria directory. Ovviamente la VM master non potrà subire modifiche ne potrà essere accesa in quanto comprometterebbe il funzionamento dei Linked Clone: in caso sia necessario aggiornare la copia originale sarà anche necessario rimuovere i Linked Clone e rigenerarli al termine delle modifiche.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Questo documento è stato generato dalla discussione seguente:&lt;A href="https://communities.vmware.com/thread/531926"&gt;vSphere Linked Clone script&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Mar 2016 16:27:35 GMT</pubDate>
    <dc:creator>rsicilia</dc:creator>
    <dc:date>2016-03-07T16:27:35Z</dc:date>
    <item>
      <title>vSphere Linked Clone script</title>
      <link>https://communities.vmware.com/t5/Italian-Documents/vSphere-Linked-Clone-script/ta-p/2775550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I LinkedClone, così come siamo abituati ad utilizzarli in Horizon View, non sono disponibili in un ambiente "solo" vSphere ma può capitare di voler gestire degli albienti applicativi come LinkedClone di una sistema "master". Già da tempo è disponibile una procedura, ovviamente ufficiosa, per la creazione di LinkedClone su vSphere ma eseguire i passi a mano può comportare un eccessivo dispendio di tempo oltre ad incappare in banali errori.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://rsiciliablog.wordpress.com/2016/03/06/vsphere-linkedclone-script/"&gt;In questo post ho riportato e spiegato una script per automatizzare un po' la procedura&lt;/A&gt; in questione e di seguito ne illustro i passaggi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Premessa: la VM indentificata come master deve essere stata configurata secondo le proprie esigenze, spenta e, una volta completato lo shutdown, è necessario eseguire una snapshot (nome a piacere).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Per prima cosa ci connettiamo al vCenter e definiamo un po’ di variabili, in particolare il nome della VM master, il path dove troviamo i files a livello ESXi/Datastore, la directory di lavoro temporanea ed il nome della VM clone che creeremo:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Add-PSSnapin VMware.VimAutomation.Core | Out-Null&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Connessione verso vCenter Server..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Connect-VIServer -Server &lt;EM&gt;10.0.0.1&lt;/EM&gt; -User &lt;EM&gt;administrator@vsphere.local&lt;/EM&gt; -Password &lt;EM&gt;pwd&lt;/EM&gt; -WarningAction SilentlyContinue&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo ""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$vmname = "VM-MASTER"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$path = "/vmfs/volumes/&lt;EM&gt;xxxxxxxx-yyyyyyyy-zzzz-wwwwwwwwwwww&lt;/EM&gt;/$vmname/"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$tempDir = "c:\LINKED-CLONE"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$cloneName = "VM-CLONE1"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Successivamente identifichiamo la VM e definiamo un “mount point” per il Datastore che la ospita così da scaricare i files che ci interessano:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$master = Get-VM -Name $vmname&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Procedura di gestione LINKED-CLONE per la guest $vmname"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$datastore = Get-Datastore "&lt;EM&gt;DS-LOCAL&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;New-PSDrive -Location $datastore -Name ds -PSProvider VimDatastore -Root "" | out-null&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Download VMX file..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Copy-DatastoreItem "ds:\$vmname\*.vmx" "$tempDir\$cloneName.vmx"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Download SNAP file..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Copy-DatastoreItem "ds:\$vmname\*-000001.vmdk" "$tempDir\"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Download DELTA file..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Copy-DatastoreItem "ds:\$vmname\*-000001-delta.vmdk" "$tempDir\"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I file scaricati sono la base per la nuova VM e vanno opportunamente modificati. Si tratta di cambiare pochi parametri quindi torna comoda la PowerShell:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Edit VMX file"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$vmx = Get-content –path "$tempDir\$cloneName.vmx"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$vmx_new = $vmx -replace "displayName = ""$vmname""", "displayName = ""$cloneName"""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Set-content "$tempDir\$cloneName.vmx" $vmx_new&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Verifica file name per $master"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$file = Get-ChildItem -path $tempDir -Filter *-000001.vmdk&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$filename = $file.Name&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Identificato file $filename"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Edit SNAP file"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$vmdk = Get-content –path "$tempDir\$filename"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;$vmdk_new = $vmdk -replace "parentFileNameHint=""", "parentFileNameHint=""$path"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Set-content "$tempDir\$filename" $vmdk_new&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Infine i files vengono caricati nel Datastore e la nuova VM aggiunta all’inventory:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Upload..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;New-Item -Path "ds:\$cloneName\" -ItemType Directory | out-null&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Copy-DatastoreItem "$tempDir\$cloneName.vmx" "ds:\$cloneName\"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Copy-DatastoreItem "$tempDir\*-000001.vmdk" "ds:\$cloneName\"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Copy-DatastoreItem "$tempDir\*-000001-delta.vmdk" "ds:\$cloneName\"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Inventory nuova VM..."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;New-VM -VMFilePath "[DS-LOCAL] $cloneName/$cloneName.vmx" -ResourcePool "MyPool"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;echo "Done!"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;La nuova VM utilizzerà, in sola lettura, il file VMDK della VM master e scriverà le proprie modifiche nei delta disk posizionati nella propria directory. Ovviamente la VM master non potrà subire modifiche ne potrà essere accesa in quanto comprometterebbe il funzionamento dei Linked Clone: in caso sia necessario aggiornare la copia originale sarà anche necessario rimuovere i Linked Clone e rigenerarli al termine delle modifiche.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Questo documento è stato generato dalla discussione seguente:&lt;A href="https://communities.vmware.com/thread/531926"&gt;vSphere Linked Clone script&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Mar 2016 16:27:35 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/Italian-Documents/vSphere-Linked-Clone-script/ta-p/2775550</guid>
      <dc:creator>rsicilia</dc:creator>
      <dc:date>2016-03-07T16:27:35Z</dc:date>
    </item>
  </channel>
</rss>

