How To Modify Collectors of Windows Exporter

Update: here’s a generalized version of this function that can be applied to other services

The follow cmdlets assumes that Prometheus Windows Exporter has already been installed. This is how to modify an existing instance:

# Example: Enabling Collectors for a Hyper-V Server
$wmiService=Get-WmiObject win32_service| ?{$_.Name -like "*$serviceName*"}
$binaryPath = '\"' + $exePath + '\"' + " --log.format logger:eventlog?name=windows_exporter --collectors.enabled $enabledCollectors"
sc.exe config $serviceName binpath= $binaryPath
sc.exe qc windows_exporter
restart-service $serviceName

Leave a Reply

Your email address will not be published. Required fields are marked *