[SCOM] Agent installation/upgrade Error 25211 Failed to install performance counters

If you have some servers where the SCOM Agent is either failing to install or get upgraded (with or without the NOAPM switch) with the following error:
„Error 2511. Failed to install performance Counters.. Error Code -2147024809 (Wrong Parameters)" and in the installation log following error "InstallPerfCountersLib: InstallHealthServicePerfCounters() failed . Error Code: 0x80070057. " you might be having an issue with the SDDL.

Apparently the SCOM installer checks the following registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Security\customsd

If the value is corrupt or an SID is invalid (the account does not exist anymore)  you might get this error.