VMware Cloud Community
vSphereUser7
Contributor
Contributor
Jump to solution

Help with VM monitoring setting at VM level

Hi, I am new to powershell and got the below script (from http://damiankarlson.com/2011/01/13/managing-vmware-has-vm-monitoring-powercli/ thanks Damian Karlson) that will allow me to set the "VM Monitoring" setting for each VM in a cluster to "Disabled" status. This is necessary to enable "VM and Application Monitoring" at top level and keep only selective VMs enabled for monitoring. When I run this script, it gets applied VM1. When i try to apply this for another VM with a change in VM name (to VM2), it get "Specified parameter was not correct” error in vCenter tasks. Not sure whats wrong, any help is appreciated.


$srv = Connect-VIServer vcenter01
$vm = Get-VM -Name VM1
$spec = New-Object VMware.Vim.ClusterConfigSpecEx
$spec.dasVmConfigSpec = New-Object VMware.Vim.ClusterDasVmConfigSpec[] (1)
$spec.dasVmConfigSpec[0] = New-Object VMware.Vim.ClusterDasVmConfigSpec
$spec.dasVmConfigSpec[0].operation = "edit"
$spec.dasVmConfigSpec[0].info = New-Object VMware.Vim.ClusterDasVmConfigInfo
$spec.dasVmConfigSpec[0].info.key = New-Object VMware.Vim.ManagedObjectReference
$spec.dasVmConfigSpec[0].info.key.type = "VirtualMachine"
$spec.dasVmConfigSpec[0].info.key.value = $vm.ExtensionData.MoRef.Value
$spec.dasVmConfigSpec[0].info.dasSettings = New-Object VMware.Vim.ClusterDasVmSettings
$spec.dasVmConfigSpec[0].info.dasSettings.vmToolsMonitoringSettings = New-Object VMware.Vim.ClusterVmToolsMonitoringSettings
$spec.dasVmConfigSpec[0].info.dasSettings.vmToolsMonitoringSettings.enabled = $false
$spec.dasVmConfigSpec[0].info.dasSettings.vmToolsMonitoringSettings.vmMonitoring = "vmMonitoringDisabled"
$spec.dasVmConfigSpec[0].info.dasSettings.vmToolsMonitoringSettings.clusterSettings = $false
$_this = Get-View -Id $vm.VMHost.Parent.Id

0 Kudos
1 Solution

Accepted Solutions
mattboren
Expert
Expert
Jump to solution

Hello, vSphereUser7-

I saw your follow-up to your thread on this topic at http://communities.vmware.com/message/1859219#1859219.  Between your response there, and your issue you mention in this thread, I came to realize what seems to be the problem for you.  I re-wrote some code in the other thread, building on what DKarlson blogged about, and commented on why you were getting this error in the vSphere client.  See that thread for more info about what is going on here.

And, let us know if that was the issue you were running in to.

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Are you using PowerCLI 5 or a pre-5 version ?


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

0 Kudos
vSphereUser7
Contributor
Contributor
Jump to solution

I am using PowerCLI 5.

0 Kudos
mattboren
Expert
Expert
Jump to solution

Hello, vSphereUser7-

I saw your follow-up to your thread on this topic at http://communities.vmware.com/message/1859219#1859219.  Between your response there, and your issue you mention in this thread, I came to realize what seems to be the problem for you.  I re-wrote some code in the other thread, building on what DKarlson blogged about, and commented on why you were getting this error in the vSphere client.  See that thread for more info about what is going on here.

And, let us know if that was the issue you were running in to.

0 Kudos