Monday 29 September 2014

Can't reuse a computer name after cancelling a VM template deployment

We all make mistakes. I often do when deploying a VM and then deciding that I should have named it something else or given it a different setting, then cancel the deployment instead of waiting for it to finish.

I did that today when I noticed it had set the wrong display name (despite having change it!!) and when I went to redeploy it refused to pick the first number in the sequence.

N.B. if you use ## within the name during deploying via a template, SCVMM will auto increment the name of the VM based on a pattern. So Server## will become Server01 the next Server02 and so on.

There's no visible store of computer names in use/reserved etc within the console, so you will need to fall back to PowerShell to clean this up.

Sometimes when you cancel deploying a VM, a temporary VM Template is left in place and this locks the name from being reused.

Type:
Get-SCVMTemplate | Where name -like "Temp*"

This will show you all the temporary templates currently knocking around.


Then either take a note of the name and run the command again with the full name while piping it to the Remove-SCVMTemplate command, or clean up all temporary VM Templates by using:

Get-SCVMTemplate | Where name -like "Temp*" | Remove-SCVMTemplate

Simples.