VMware Cloud Community
mhorgan61
Contributor
Contributor
Jump to solution

Can't find VM Templates using 'Get-Template' command

Hi all,

Apologies if this question has been asked before but haven't been able to find any information on it.

For some reason when I use the Get-Template command within PowerCLI I get no results even though I have templates on the datastore. Using a command such as Get-VM works as expected but for some reason the Get-Template command just won't find anything. Is there anything glaringly obvious that I may have missed out perhaps in the configuration of my virtual environment?

The environment consists of one Datacenter with one ESXi 5.1 host and multiple VMs residing on it. I also have a vCenter virtual appliance to manage the host.

Thanks,

Matt

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ssbkang
Enthusiast
Enthusiast
Jump to solution

Hi Matt,

When you run Connect-VIServer, do you connect to ESXi or vCenter server?

I've just tested both:

  • Connect-VIServer -Server ESXi
    • Get-Template didn't retrieve any data
  • Connect-VIServer -Server vCenter
    • Get-Template retrieved data

Maybe this is the case?

Hope this helps,

Steven.

View solution in original post

0 Kudos
7 Replies
ssbkang
Enthusiast
Enthusiast
Jump to solution

Hi Matt,

You have mentioned that the templates are on the datastore. You need to make sure they are registered to the vCenter server.

I've just tried Get-Template command myself and I was able to retrieve information on all the templates!

-Steven

0 Kudos
mhorgan61
Contributor
Contributor
Jump to solution

Hi Steven, thanks for the response.

The template was already registered to the vCenter server but I removed it and re-added it and still no luck seeing it with the Get-Template command.

I've attached a screenshot of the setup to try and show what I mean.

Thanks,

Matttemplate_problem.png

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Does this return your templates ?

Get-View -ViewType VirtualMachine -Filter @{"Summary.Config.Template"="True"} |
Select Name


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

0 Kudos
mhorgan61
Contributor
Contributor
Jump to solution

Hi LucD,

No, that command doesn't return anything. I'm currently using the evaluation licence for both ESXi and vCenter - would this make a difference in regards to accessing the full API?

Thanks,

Matt

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Normally the "free" ESXi license has some limitations, it will only allow you to read, and not write, anything to the vSphere environment from PowerCLI.

But with an evaluation license it should all work.

A stupid test, can you can create a new template, and then check if it is listed.

Something like this

$vm = Get-VM -Name <any-vm>

Set-VM -VM $vm -ToTemplate

Get-Template


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

ssbkang
Enthusiast
Enthusiast
Jump to solution

Hi Matt,

When you run Connect-VIServer, do you connect to ESXi or vCenter server?

I've just tested both:

  • Connect-VIServer -Server ESXi
    • Get-Template didn't retrieve any data
  • Connect-VIServer -Server vCenter
    • Get-Template retrieved data

Maybe this is the case?

Hope this helps,

Steven.

0 Kudos
mhorgan61
Contributor
Contributor
Jump to solution

Hi guys, thanks for the response.

Turns out that I had been mistakenly been connecting to my ESXi host and not the vCenter server itself. When I connect to the vCenter server everything behaves as expected.

Thanks!

0 Kudos