I'd like to be able to discover Performance Counter instance natively via the Windows Agent. This way Discovery Rules can be created for the automated monitoring of Multi-Instance Performance Counters such as Process, PhysicalDisk, LogicalDisk, Paging File, etc.
I initially used a PowerShell script to discover Perf Counter instances but realized most of the work is already done in the Agent source and is a much preferred method.
The following code has worked nicely for me (Agent sources v2.2.1)
<moved to comments below>