VMware Cloud Community
vcpguy
Expert
Expert

unregistered template

Hi,

I need to find a script that will scan all my datastores for un-register tempaltes.

Any ideas?

Thanks

----------------------------------------------------------------------------- Please don't forget to reward Points for helpful hints; answers; suggestions. My blog: http://vmwaredevotee.com
Tags (2)
0 Kudos
5 Replies
LucD
Leadership
Leadership

A template is in practice the same as a virtual machine with a few differences.

The config file is not a .VMX but a .VMTX file and the VirtualMachine object contains a flag, called Template, which indicates if it concerns a virtual machine or a template.

So I took one of my "find unregistered VMX files" scripts and with a few adaptations it now should be able to find unregistered templates.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
kleofas2
Contributor
Contributor

Hi LucD

Could this script be easily modified to find and register these templates?

Thanks

Tomasz

0 Kudos
LucD
Leadership
Leadership

The script in my Raiders of the Lost VMX post does exactly that.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
kleofas2
Contributor
Contributor

Thanks LucD

Great script - helped me a lot in restoring my templates from the datastore.

We have them more than 100 so registering them manually could take an infinity.

One thing - If I can suggest.

When registering the vCenter firstly registers full name of the VM including datastore ID etc. like:

sanfs.JPG

If you have many templates with long, similar name and different ending - then vCenter throws many error messages.

message.JPG

In fact - first and second machines were different and differed with just ending. After a while the long format was replaced by the shorter one (without datastore ID).

I solved this problem by adding "sleep 30" after the line 95:

$taskMoRef =$tgtfolder.GetType().GetMethod("RegisterVM_Task").Invoke($tgtfolder, $params)

It caused that each registration was 30 seconds longer but the script didn't generate so much errors and don't have to be executed multiple times.

Maybe the method is not elegant 🙂 I'm not a powerCLI expert, but it works.

0 Kudos
LucD
Leadership
Leadership

That's an interesting discovery you made.

I suspect this caused by the way the RegisterVM_Task works internally.

I'l see if I can come up with a bypass.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos