Hello All,
I have done some serious googling, and am about to accept that it is not possible through PowerCLI.
But I wanted to make a last effort by asking you guys.
For ESXi host maintenance, I want to use a PowerCLI script which does this:
Because we have 300+ ESXi hosst, you can imagine I want to do this scripted.
Is there any way to disable/enable alarm actions through PowerCLI ?
Thanks and kind regards,
Harold
Since then the cmdlets Get-AlarmDefinition and Set-AlarmDefinition were introduced.
You can easily enable/disable an alarm with those cmdlets.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks
It is not working now in the new version PowerCli. I'm getting below error.
Exception calling "EnableAlarmActions" with "2" argument(s): "The object 'vim.HostSystem:host-266712' has already been deleted or has not been completely created"
At line:1 char:1
+ $alarmMgr.EnableAlarmActions($esx.Extensiondata.MoRef,$true)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
Same error here: "Exception calling "EnableAlarmActions" with "2" argument(s): "The object 'vim.HostSystem:host-102792' has already been deleted or has not been completely created"
For an hour I've been trying to find a working method to disable alarm actions for all hosts in a cluster via PowerCLI. I'm about to give up and just tell my colleagues to ignore the alarms. Nothing works!
Did you stop/start your PowerShell session in between tries?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It works for a colleague. I think my PowerShell is broken.
167 ms | C:\Users\e12> Set-PSDebug -Trace 2
9 ms | C:\Users\e12> $alarmMgr.EnableAlarmActions($esx.Extensiondata.MoRef,$false)
DEBUG: 1+ >>>> $alarmMgr.EnableAlarmActions($esx.Extensiondata.MoRef,$false)
DEBUG: ! CALL function '<ScriptBlock>'
DEBUG: 19+ if ( & >>>> { Set-StrictMode -Version 1; $_.PSMessageDetails } ) {
DEBUG: ! CALL function '<ScriptBlock>'
DEBUG: 19+ if ( & { >>>> Set-StrictMode -Version 1; $_.PSMessageDetails } ) {
DEBUG: 19+ if ( & { Set-StrictMode -Version 1; >>>> $_.PSMessageDetails } ) {
DEBUG: 1+ & >>>> { Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails }
DEBUG: ! CALL function '<ScriptBlock>'
DEBUG: 1+ & { >>>> Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails }
DEBUG: 1+ & { Set-StrictMode -Version 1; >>>> $this.Exception.InnerException.PSMessageDetails }
DEBUG: 1+ & { Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails >>>> }
DEBUG: 19+ if ( & { Set-StrictMode -Version 1; $_.PSMessageDetails >>>> } ) {
DEBUG: 26+ $errorCategoryMsg = & >>>> { Set-StrictMode -Version 1; $_.ErrorCategory_Message }
DEBUG: ! CALL function '<ScriptBlock>'
DEBUG: 26+ $errorCategoryMsg = & { >>>> Set-StrictMode -Version 1; $_.ErrorCategory_Message }
DEBUG: 26+ $errorCategoryMsg = & { Set-StrictMode -Version 1; >>>> $_.ErrorCategory_Message }
DEBUG: 26+ $errorCategoryMsg = & { Set-StrictMode -Version 1; $_.ErrorCategory_Message >>>> }
DEBUG: 42+ $originInfo = & >>>> { Set-StrictMode -Version 1; $_.OriginInfo }
DEBUG: ! CALL function '<ScriptBlock>'
DEBUG: 42+ $originInfo = & { >>>> Set-StrictMode -Version 1; $_.OriginInfo }
DEBUG: 42+ $originInfo = & { Set-StrictMode -Version 1; >>>> $_.OriginInfo }
DEBUG: 42+ $originInfo = & { Set-StrictMode -Version 1; $_.OriginInfo >>>> }
Exception calling "EnableAlarmActions" with "2" argument(s): "The object 'vim.HostSystem:host-83069' has already been deleted or has not been completely created"
At line:1 char:1
+ $alarmMgr.EnableAlarmActions($esx.Extensiondata.MoRef,$false)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
Posting this in case it helps someone.
I got this error as well. I think it was because in testing I had 2 connections to vcenter.
When I used get-vmhost, I had double entries for each system.
I disconnected my connections and tried again (commenting out my connect line after I entered my creds as I was debugging)
I didn't see the error after that.
Hi
Is it possible to get the Alarms-Status for every element in vCenter: Clusters, Hosts, Vms, Datastore, Networks ?
We hat the Alarms disabled for one Hosts, and for one Storage. The Infrastructure has 9 Hosts, 250 VMs, 30-40 NFS Datastores, and dSwitches. To check them manually...not a good idea 🙂
Thanks
Would this work for you?
Get-AlarmDefinition |
Select Name, @{N='Entity';E={$_.Entity.Name}},Enabled
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi.
Thank you for the time.
No. I can find this script output in the AlarmDefinition of the vCenter.
What I need to see if any of the Hosts, VMs or Datastores have the option "Alarms -> Disable Alarm Actions" - from the Right click Menu - disabled.
Have a nice day.
You mean something like this?
Get-Inventory |
Select Name,
@{N='Type';E={$_.GetType().Name.Replace('Impl','')}},
@{N='AlarmActionsEnabled';E={$_.ExtensionData.AlarmActionsEnabled}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi
Perfect.
Together with the
Get-Datastore | Select Name, @{N='Type';E={$_.GetType().Name.Replace('Impl','')}}, @{N='AlarmActionsEnabled';E={$_.ExtensionData.AlarmActionsEnabled}}
I have manage to find some VMs and some Storages that had the Alarms disabled.
Thank you!
Hi LucD,
Sorry for awakening this old thread, but I had a related question:
I suspect there are individual hosts in my environment which have the alarm actions disabled. Is there a simple way to get a list of all of them that are in this state?
Thanks.
Try something like this
Get-VMHost |
Where{-not $_.ExtensionData.AlarmActionsEnabled} |
Select Name,
@{N='AlarmActionsEnabled';E={$_.ExtensionData.AlarmActionsEnabled}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD!
I did some testing and noticed that this only was showing hosts that had the setting, very simple to check the clusters using the same logic and just changing to get-cluster:
Get-Cluster |
Where{-not $_.ExtensionData.AlarmActionsEnabled} |
Select Name,
@{N='AlarmActionsEnabled';E={$_.ExtensionData.AlarmActionsEnabled}}