Finding Templates with PowerCLI

Although this doesn’t happen often sometimes I find that I have misplaced a template.

I mean that a template I know exists is not in the inventory and I am not sure on which datastore I need to go to re-add it back to the inventory. Granted I don’t personally have many datastores to look through so it wouldn’t take me that long to manually look through them, but why not just easily have powershell/powercli do it for you.

First you need to connect to your vcenter with the “connect-viserver” cmdlet.

Then change to the psdrive vmstore, and finally search for the template with get-childitem -recurse -include *.vmtx

PowerCLI Template Search

What I blocked out here is the datastore.

That’s it! This may take a Long While to run. Like a Long While, but it allows you to go do other things during the search so you don’t have to.

If you want to invest a little more time, you can search directly on the host vis ssh or VMA

Once in the host just use

find -name *.vmtx

SSH Find Template

This one takes significantly less time but requires you to be attached to a host.

Hope this helps!

Leave a Reply