WMI and Go... where to get started?

482 views
Skip to first unread message

Tom Limoncelli

unread,
Feb 7, 2021, 3:20:09 PM2/7/21
to golang-nuts
I've been using Unix for decades (and Go since the pre-releases) and
now I find myself needing to use Go to talk to the Windows WMI system.
There isn't a lot of GO-specific documentation and I could use help
figuring out where to get started. Sadly google searches for getting
started with WMI are about as useful as learning to perform surgery by
googling for "broken bone".

I'm trying to use WMI to talk to the Windows DNS Server. My MVP would
be to do the equivalent of adding an A or MX record to an existing DNS
zone (similar to
https://docs.microsoft.com/en-us/windows/win32/dns/dns-wmi-provider-samples-managing-dns-resource-records)

Can anyone point me in the right direction? What are the best
resources for learning WMI in general?

Thanks in advance!
Tom

Brian Candler

unread,
Feb 8, 2021, 9:56:58 AM2/8/21
to golang-nuts
I suggest you take a look at the prometheus wmi_exporter / windows_exporter.  This is focussed on collecting metrics, not doing DNS updates, but it may give you a starting point.

Note: windows_exporter is the newer version, and I think they've actually moved away from WMI in many of the collectors to use more efficient interfaces; but looking through the git history should tell you a lot.

Aravindhan K

unread,
Feb 8, 2021, 10:12:19 AM2/8/21
to Tom Limoncelli, golang-nuts
Hi,
I don't think there exists WMI client implementation in Go.
 You could try cgo with samba WMI implementation


Thanks,
Aravindhan K

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAHVFxgnqjd%2BwZjYiJ3YyhHDFaVHuTEQCrapiECaTzFvFY8qNMA%40mail.gmail.com.

Brian Candler

unread,
Feb 8, 2021, 10:29:19 AM2/8/21
to golang-nuts
Looking at windows_exporter's go.mod file, it uses github.com/StackExchange/wmi.  The comments there say it talks to WMI on the local machine, not WMI over the network.
Reply all
Reply to author
Forward
0 new messages