I am using this WMI library for executing WQL query in Go language. I am able to execute the sample code in local machine. However, I need to execute the WQL query on a remote machine. The documentation for the Query
method I use reads as shown below:
By default, the local machine and default namespace are used. These can be changed using connectServerArgs. See http://msdn.microsoft.com/en-us/library/aa393720.aspx for details.
However, I am not sure how to pass the connectServerArgs
correctly. Could somebody please help me with a sample declaration of this argument and how to pass it to Query
method?
According to the docs, the signature of ConnectServer
method is:
objwbemServices = .ConnectServer( _
[ ByVal strServer ], _
[ ByVal strNamespace ], _
[ ByVal strUser ], _
[ ByVal strPassword ], _
[ ByVal strLocale ], _
[ ByVal strAuthority ], _
[ ByVal iSecurityFlags ], _
[ ByVal objwbemNamedValueSet ] _
)
so try something like:
c.Query(wqlQery, dst, "your-remote.server.net or IP address",
"root\CIMV2", "DomainName\UserName", "secret password")