VMware Cloud Community
krisnz
Contributor
Contributor
Jump to solution

vCheck Report exclude specific cluster

How can use the vCheck Daily report to exclude specific cluster and all the Hosts, Datastores, VM's, warnings etc within that cluster from reporting..

http://www.virtu-al.net/vcheck-pluginsheaders/vcheck/

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The Get-View cmdlet doesn't have a Location parameter, it uses the SearchRoot to do the same thing.

Taking that into account, it could be something like this

Write-CustomOut "Collecting Detailed VM Objects" 
$FullVM
= $Clusters | %{   Get-View -ViewType VirtualMachine -SearchRoot $_.ExtensionData.MoRef `
 
-Filter @{"Config.Template"="False"} }

Notice the use of the Filter parameter to replace the Wher-clause.

But you can also use the fact that the ExtensionData property maps to the vSphere object.

And then the code could be something like this

$ReportCluster = "clust01","clust02","clust03","clust04" 
Write-CustomOut
"Collecting Cluster Objects"
$Clusters = Get-Cluster -Name $ReportCluster | Sort Name
Write-CustomOut
"Collecting VM Objects"
$VM
= Get-VM -Location $Clusters | Sort Name
Write-CustomOut
"Collecting VM Host Objects"
$VMH
= Get-VMHost -Location $Clusters | Sort Name
Write-CustomOut "Collecting Datastore Objects"
$Datastores
= Get-Datastore -Location $Clusters | Sort Name
Write-CustomOut
"Collecting Detailed VM Objects"
$FullVM
= $VM | %{$_.ExtensionData} Write-CustomOut "Collecting Template Objects"
$VMTmpl
= Get-Template -Location $Clusters
Write-CustomOut
"Collecting Detailed VI Objects"
$ServiceInstance = get-view ServiceInstance
Write-CustomOut
"Collecting Detailed Alarm Objects"
$alarmMgr
= get-view $serviceInstance.Content.alarmManager
Write-CustomOut
"Collecting Detailed VMHost Objects"
$HostsViews = $VMH | %{$_.ExtensionData} Write-CustomOut "Collecting Detailed Cluster Objects"
$clusviews = $Clusters | %{$_.ExtensionData} Write-CustomOut "Collecting Detailed Datastore Objects"
$storageviews
= $Datastores | %{$_.ExtensionData}


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

View solution in original post

0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

Afaik such functionality is not foreseen in the current vCheck script.

But you achieve something like this by editing the 00 Connection Plugin for vCenter.ps1 file.

In that file all the VMs, Hosts, Clusters... are collected. By editing these lines you can easily exclude a specific cluster and all its child nodes.

For example:

$excludeName = "NotThisCluster"

Write-CustomOut "Collecting Cluster Objects"
$Clusters = Get-Cluster |  Where {$_.Name -ne $excludeName} | Sort Name

....

And then you get the VMs, hosts, datastore only for the selected clusters.

Write-CustomOut "Collecting VM Objects"
$VM = Get-VM -Location $Clusters | Sort Name
...


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

0 Kudos
krisnz
Contributor
Contributor
Jump to solution

Appreciate your quick reply.

I tried the following but its not filtering all the child objects

Write-CustomOut "Collecting Cluster Objects"
$Clusters = Get-Cluster | Sort Name | select name | where {$_.name -match 'xxxx'}
0 Kudos
LucD
Leadership
Leadership
Jump to solution

In the code you used the $cluster variable will only contain the name of the cluster, not the cluster object as the vCheck script expects.

Did you also adapt the other Get- lines with the Location parameter ?


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

0 Kudos
krisnz
Contributor
Contributor
Jump to solution

will this work.. and do i need to add location for get-view

$ReportCluster = "clust01","clust02","clust03","clust04"
Write-CustomOut "Collecting Cluster Objects"
$Clusters = Get-Cluster | Where {$_.Name -eq $ReportCluster} | Sort Name
Write-CustomOut "Collecting VM Objects"
$VM = Get-VM -Location $Clusters | Sort Name
Write-CustomOut "Collecting VM Host Objects"
$VMH = Get-VMHost -Location $Clusters | Sort Name
Write-CustomOut "Collecting Datastore Objects"
$Datastores = Get-Datastore -Location $Clusters | Sort Name
Write-CustomOut "Collecting Detailed VM Objects"
$FullVM = Get-View -ViewType VirtualMachine | Where {-not $_.Config.Template}
Write-CustomOut "Collecting Template Objects"
$VMTmpl = Get-Template -Location $Clusters
Write-CustomOut "Collecting Detailed VI Objects"
$ServiceInstance = get-view ServiceInstance
Write-CustomOut "Collecting Detailed Alarm Objects"
$alarmMgr = get-view $serviceInstance.Content.alarmManager
Write-CustomOut "Collecting Detailed VMHost Objects"
$HostsViews = Get-View -ViewType hostsystem
Write-CustomOut "Collecting Detailed Cluster Objects"
$clusviews = Get-View -ViewType ClusterComputeResource
Write-CustomOut "Collecting Detailed Datastore Objects"
$storageviews = Get-View -ViewType Datastore
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The Get-View cmdlet doesn't have a Location parameter, it uses the SearchRoot to do the same thing.

Taking that into account, it could be something like this

Write-CustomOut "Collecting Detailed VM Objects" 
$FullVM
= $Clusters | %{   Get-View -ViewType VirtualMachine -SearchRoot $_.ExtensionData.MoRef `
 
-Filter @{"Config.Template"="False"} }

Notice the use of the Filter parameter to replace the Wher-clause.

But you can also use the fact that the ExtensionData property maps to the vSphere object.

And then the code could be something like this

$ReportCluster = "clust01","clust02","clust03","clust04" 
Write-CustomOut
"Collecting Cluster Objects"
$Clusters = Get-Cluster -Name $ReportCluster | Sort Name
Write-CustomOut
"Collecting VM Objects"
$VM
= Get-VM -Location $Clusters | Sort Name
Write-CustomOut
"Collecting VM Host Objects"
$VMH
= Get-VMHost -Location $Clusters | Sort Name
Write-CustomOut "Collecting Datastore Objects"
$Datastores
= Get-Datastore -Location $Clusters | Sort Name
Write-CustomOut
"Collecting Detailed VM Objects"
$FullVM
= $VM | %{$_.ExtensionData} Write-CustomOut "Collecting Template Objects"
$VMTmpl
= Get-Template -Location $Clusters
Write-CustomOut
"Collecting Detailed VI Objects"
$ServiceInstance = get-view ServiceInstance
Write-CustomOut
"Collecting Detailed Alarm Objects"
$alarmMgr
= get-view $serviceInstance.Content.alarmManager
Write-CustomOut
"Collecting Detailed VMHost Objects"
$HostsViews = $VMH | %{$_.ExtensionData} Write-CustomOut "Collecting Detailed Cluster Objects"
$clusviews = $Clusters | %{$_.ExtensionData} Write-CustomOut "Collecting Detailed Datastore Objects"
$storageviews
= $Datastores | %{$_.ExtensionData}


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

0 Kudos
krisnz
Contributor
Contributor
Jump to solution

explained really well. thanks

0 Kudos