VMware Cloud Community
pasalott
Enthusiast
Enthusiast

Powershell script to enable alarms in vCenter stopped working after upgrade to vCenter 7 U3

Powershell script to enable alarms in vCenter stopped working after upgrade from vCenter 6.7 U3 to vCenter 7.0 U3.

Please see attached script

 

Receive error:

Exception calling "EnableAlarmActions" with "2" argument(s): "
Required parameter entity is missing
while parsing call information for method EnableAlarmActions
at line 1, column 171
while parsing SOAP body
at line 1, column 64
while parsing SOAP envelope
at line 1, column 0
while parsing HTTP request for method setAlarmActionsEnabled
on object of type vim.alarm.AlarmManager
at line 1, column 0"
At line:21 char:5
+ $a.EnableAlarmActions($vh.ExtensionData.MoRef,$true)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException

0 Kudos
6 Replies
LucD
Leadership
Leadership

What is

Get-VMHost -Server:$vs

returning?
It looks like the $vh.ExtensionData.MoRef property is not returning anything for one of your ESXi nodes.


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

0 Kudos
pasalott
Enthusiast
Enthusiast

This happens for every host and for all cluster level alarms as well.  This same script has been working fine in vCenter 6.7.  I'm just trying to figure out what changed in vCenter 7 U3 that caused this script to no longer function

0 Kudos
LucD
Leadership
Leadership

The EnableAlarmActions method hasn't changed since API 4.0.

The error is very clear imho, there is no value for Entity ($vh.EXtensionData.MoRef) in one of the calls.


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

0 Kudos
pasalott
Enthusiast
Enthusiast

This exact script works fine in our vSphere 6.7 U3 test environment.  vCenter 7 U3 has an issue with this script for some reason.  Why would this script function in vCenter 6.7 U3 but not vCenter 7.0 U3, if nothing has changed?

It's not one call, it's everything.  We receive the errors specified in my original post on every cluster and host.  I run the script in 6.7 U3, no issues.  It fails for everything in vCenter 7 U3

0 Kudos
LucD
Leadership
Leadership

Your code works perfectly fine in my 7U3 environment.
You should probably debug the code line by line to see what exactly goes wrong in your environment.
You could do that in Visual Code with the built-in debugger.


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

0 Kudos
pasalott
Enthusiast
Enthusiast

updating PowerCLI resolved the issue

0 Kudos