Was troubleshooting this little error message for a customer after deploying the SQL Server Management Pack version 220.127.116.11.
The event is the generic “Health Service Script” with id 4001.
Management Group: REDACTED. Script: Main Module: CPUUsagePercentDataSource.ps1 :
There are some known errors to the 18.104.22.168 version of the SQL management packs, and one of them does mention “Cannot add type. Compilation errors occured.”
In a thread on the Technet Forums it was suggested that it has to do with rights, but focusing mainly on the SQL instance. What caught our eyes, however, was the fact that the script is using the
C:\Windows\TEMP folder instead of its private one. And this seems to be because it is using a few .Net components that do some sort of JIT compilation.
We took a quick look using procmon, filtered on C:\Windows\TEMP\ and yes indeed. The monitoring account used is trying to create and delete its temporary files in that very folder.
The work-around is simple, but cumbersome. Just make sure that the assigned RunAs account have read/write/delete rights on C:\Windows\TEMP.
Now you just have to manage this on all your SQL-servers! (yaaaay)