Created
June 4, 2017 12:07
-
-
Save atzimler/41e1ea95c29552e03a0c77687f10f2b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$TemplateDirectory = $env:TEMPLATE_DIRECTORY | |
$ImageDirectory = $env:IMAGE_DIRECTORY | |
$Image = $env:IMAGE | |
$Template = $env:TEMPLATE | |
$vmcx = ls "$TemplateDirectory\$Template\Virtual Machines\*.vmcx" | |
$path = "$TemplateDirectory\$Template\Virtual Machines\" + $vmcx.Name | |
$vmpath = "$ImageDirectory\$Image" | |
Import-VM -Path $path -Copy -GenerateNewId -VirtualMachinePath $vmpath -VhdDestinationPath "$vmpath\Virtual Hard Disks" | |
$vm = Get-VM | Where {$_.Path.StartsWith($vmpath)} | |
Rename-VM $vm -NewName $Image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment