Automation

 View Only
  • 1.  Help with VM monitoring setting at VM level

    Posted Nov 07, 2011 08:02 PM

    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



  • 2.  RE: Help with VM monitoring setting at VM level

    Posted Nov 07, 2011 10:16 PM

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



  • 3.  RE: Help with VM monitoring setting at VM level

    Posted Nov 08, 2011 12:35 AM

    I am using PowerCLI 5.



  • 4.  RE: Help with VM monitoring setting at VM level
    Best Answer

    Posted Nov 08, 2011 03:06 AM

    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.