I'm trying to find templates that exist in a cluster - but the -location param on the get-template cmdlet doesn't seem to work. Any thoughts on a workaround?
FYI - using 4.1 U1 build 332441
Thanks in advance!
The same principle as your solution but perhaps a bit shorter.
$clusName = "MyCluster"
$esx = Get-Cluster -Name $clusName | Get-VMHost | %{$_.Extensiondata.MoRef} $templates = Get-Template | where {$esx -contains $_.Extensiondata.Runtime.Host}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi John,
"Location" is a vSphere container object such as a datacenter, a cluster or a host. Is it the case for your object "MYTEMPLATE"? Strange name for a cluster...
Hope it helps.
Regards
Franck
There seems to be indeed a problem with a cluster as the location.
The -Location parameter works perfectly with a folder or a datacenter but apparently not with a cluster, although the documentation for Get-Template says it should.
It fails in both variations
Get-Template -Location ClusterName
Get-Template -Location (Get-Cluster ClusterName)
I wonder if this isn't a documentation error ?
Templates are visible in "blue" folders (the VMs & Templates view) and that view shows datacenters and folders but not clusters.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
In my haste to obscure the "real" name of my cluster I did a silly and confusing substitution. Sorry about that. 🙂
The following is very ugly but does the job. Very open to better solutions 🙂
The same principle as your solution but perhaps a bit shorter.
$clusName = "MyCluster"
$esx = Get-Cluster -Name $clusName | Get-VMHost | %{$_.Extensiondata.MoRef} $templates = Get-Template | where {$esx -contains $_.Extensiondata.Runtime.Host}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Super duper cool! I'm very new to powershell... awesome tip... Thanks!