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.
Could this script be easily modified to find and register these templates?
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:
If you have many templates with long, similar name and different ending - then vCenter throws many error messages.
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:
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.
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.