denjoh44
Enthusiast
Enthusiast

Template find the esx

Jump to solution

With commands powercli, how find the esx of the Template, without change the Template to(in) vm?

thanks you for your help

0 Kudos
1 Solution

Accepted Solutions
ccalvetTCC
Enthusiast
Enthusiast

Get-template | select Name,@{Name="Host";Expression={(get-view $_.HostId).Name}}

Blog: http://thecrazyconsultant.com/ | Twitter: @ccalvetTCC

View solution in original post

0 Kudos
4 Replies
ccalvetTCC
Enthusiast
Enthusiast

Get-template | select Name,@{Name="Host";Expression={(get-view $_.HostId).Name}}

Blog: http://thecrazyconsultant.com/ | Twitter: @ccalvetTCC
0 Kudos
TScalzott
Enthusiast
Enthusiast

How about this?

$Templates = @()

$Hosts = Get-VMHost

foreach ($h in $hosts) {

    $HostTemplates = Get-Template -Location $h

    foreach ($t in $HostTemplates) {

        $TemplateInfo = New-Object PSObject

        $TemplateInfo | Add-Member -MemberType NoteProperty Name -Value $t.Name

        $TemplateInfo | Add-Member -MemberType NoteProperty Host -Value $h.Name

        $Templates += $TemplateInfo

    }

}

$Templates

0 Kudos
TScalzott
Enthusiast
Enthusiast

That's certainly much more elegant. I need to learn how to use Get-View!

0 Kudos
denjoh44
Enthusiast
Enthusiast
  • Get-template | select Name,@{Name="Host";Expression={(get-view $_.HostId).Name}}

it's ok for me

thank  for your response

0 Kudos