Error running a Demo SCOM Agent Initiated Maintenance Mode SCCM Service Windows Script on Agent

AdamMohamed-3032 56 Reputation points
2023-08-20T06:42:26.9266667+00:00

Hi All,

Can someone please help me with the below issue ?

Recently we have imported the Kevin's Maintenance mode management in our environment.

Post importing that i'm receiving the below alert very often for all the agents.

Could someone please check and let me know how to fix this issue ?

link : https://kevinholman.com/2019/07/28/scom-agent-initiated-maintenance-mode-with-sccm-maintenance-windows/

Issue : User's image

Thanks,

Adam

Operations Manager
Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,417 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. XinGuo-MSFT 14,461 Reputation points
    2023-08-21T09:11:10.3966667+00:00

    Hi,

    The error message you've provided indicates that there is an issue with the execution of a PowerShell script (Demo.SCOM.AgentMaintenanceMode.SCCMServiceWindows.Rule.ps1) associated with a rule for SCOM Agent Initiated Maintenance Mode. Specifically, it appears that the script is encountering a problem when trying to query the SCCM Client via WMI .

    Here's a breakdown of the error message and potential steps to resolve it:

    Error Message Analysis:

    FATAL ERROR: Unable to query to SCCM Client WMI Namespace for the Root\CCM\Sms\Client class: This part of the error suggests that the script is unable to access the SCCM Client WMI namespace. You cannot call a method on a null-valued object: This is a common error in PowerShell, indicating that the script is trying to perform an operation on an object that is null or empty. Troubleshooting Steps:

    1. Check SCCM Client Status:

    Verify that SCCM Clients are installed and functioning correctly on the affected agents. This error suggests that the script cannot access SCCM Client information via WMI.

    1. WMI Namespace Permissions:

    Ensure that the account running the script has the necessary permissions to query the SCCM WMI namespace. Permissions issues can often lead to WMI query failures.

    1. Check for SCCM Client Errors:

    Check the SCCM Client logs (e.g., ccmexec.log) on the affected agents for any errors or issues that might be preventing WMI queries.

    1. Test Script Manually:

    Attempt to run the script manually on an affected agent and see if you encounter the same error. This can help you isolate the problem.


  2. Marius Ene 335 Reputation points
    2024-01-06T00:50:46.3666667+00:00

    Hi Adam,

    The message "FATAL ERROR: ... Terminating script" is added by the creator of the script. The real error message is "you cannot call a method on a null valued expression". While its pretty self explanatory it can seem cryptic. It means that the script was calling a method from an object that does not exist, that is empty.

    The whole MP xml is available here and you can see it on line 312: https://github.com/thekevinholman/MaintenanceModeFromSCCMWindow/blob/master/Demo.SCOM.AgentMaintenanceMode.xml

    User's image

    I suggest to try those 3 PowerShell commands on the server that reported the issue and see what is failing:

    $GetSCCMClientVersion = Get-WmiObject -NameSpace root\CCM -Class Sms_Client | Select-Object ClientVersion
    $SCCMClientVersion = $GetSCCMClientVersion.ClientVersion
    [int]$SCCMClientMajorVersion = $SCCMClientVersion.Split(".")[0]
    

    The failing error should be with the ".ClientVersion" method, because most likely $GetSCCMClientVersion is empty.

    Good luck!

    0 comments No comments