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..
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
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
Appreciate your quick reply.
I tried the following but its not filtering all the child objects
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
will this work.. and do i need to add location for get-view
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
explained really well. thanks