<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: wmi WQL query using hostname variable in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/wmi-WQL-query-using-hostname-variable/m-p/583266#M102771</link>
    <description>&lt;P&gt;No. As I wrote before, there is no templating within the config file.&lt;/P&gt;&lt;P&gt;Some specific values can have "template values" like decideonstartup mentioned by you but that only works for that particular variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Feb 2022 19:09:34 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2022-02-01T19:09:34Z</dc:date>
    <item>
      <title>wmi WQL query using hostname variable</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/wmi-WQL-query-using-hostname-variable/m-p/583050#M102732</link>
      <description>&lt;P&gt;I am trying to get data into Splunk to show the members of the local / builtin windows groups. In particular "Administrators" and "Remote Desktop Users"&lt;/P&gt;&lt;P&gt;Utilizing the Splunk Forwarder. I am using a WMI (WQL) query to do this via wmi.conf (C:\Program Files\SplunkUniversalForwarder\etc\apps\Splunk_TA_windows\local\wmi.conf)&lt;/P&gt;&lt;P&gt;This stanza currently works:&lt;/P&gt;&lt;P&gt;(FYI: &lt;FONT color="#FF0000"&gt;Fakenameofserver&lt;/FONT&gt; = hostname)&lt;/P&gt;&lt;P&gt;disabled = 0&lt;BR /&gt;## Run once per day ## edited&lt;BR /&gt;interval = 86400&lt;BR /&gt;wql = ASSOCIATORS OF {win32_group.Domain="&lt;FONT color="#FF0000"&gt;Fakenameofserver&lt;/FONT&gt;",Name="Administrators"} where assocClass=win32_groupuser Role=GroupCompOnent ResultRole=Partcomponent&lt;BR /&gt;index = window&lt;/P&gt;&lt;P&gt;I don't want to have to prefill the wql queries in the wmi.conf file with the server name on each server. How do i use an environmental or Splunk variable to replace&amp;nbsp;"&lt;FONT color="#FF0000"&gt;Fakenameofserver&lt;/FONT&gt;" with the name of the host the Splunk forwarder is running on. I have tried a number of combinations of $host, %host%, %servername%, %computername% etc etc.&lt;/P&gt;&lt;P&gt;Everytime i restart the forwarder to force the query to run i don't get any data into splunk and the log file says:&lt;/P&gt;&lt;P&gt;Error occurred while trying to retrieve results from a WMI query (error="Object cannot be found." HRESULT=80041002) (root\cimv2: ASSOCIATORS OF {win32_group.Domain="%VARIABLENAME%",Name="Remote Desktop Users"} where assocClass=win32_groupuser Role=GroupCompOnent ResultRole=Partcomponent)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone had success with this and can you suggest how i can get the stanza to resolve the variable into the value when it queries?&lt;BR /&gt;Where should i define the variables (if required) and what syntax do i use when writing these in the wql query?&lt;/P&gt;&lt;P&gt;Thanks for any suggestions.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jan 2022 06:29:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/wmi-WQL-query-using-hostname-variable/m-p/583050#M102732</guid>
      <dc:creator>WinAdmin456</dc:creator>
      <dc:date>2022-01-31T06:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: wmi WQL query using hostname variable</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/wmi-WQL-query-using-hostname-variable/m-p/583051#M102733</link>
      <description>&lt;P&gt;Unless something changed lately and I missed it, splunk's support for environment variables is limited only to internal SPLUNK_* ones. So there is no mechanism built into splunk to resolve such variable.&lt;/P&gt;&lt;P&gt;The WQL query is provided as is so there is also no substitution there.&lt;/P&gt;&lt;P&gt;You'd best use some external tool (puppet, ansible...) to templatize the config and deploy the app.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jan 2022 07:09:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/wmi-WQL-query-using-hostname-variable/m-p/583051#M102733</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-01-31T07:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: wmi WQL query using hostname variable</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/wmi-WQL-query-using-hostname-variable/m-p/583163#M102757</link>
      <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;Is there a way to create a variable within the splunk forwarder that could be used rather than trying to use a windows env variable.&lt;/P&gt;&lt;P&gt;I read about a way to decideonstartup the hostname and that could be referenced from the input.conf file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or&lt;/P&gt;&lt;P&gt;Can i create a value in input.conf or another conf file that i can reference just to prove that the WMI query can resolve the variable in the query string?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 06:19:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/wmi-WQL-query-using-hostname-variable/m-p/583163#M102757</guid>
      <dc:creator>WinAdmin456</dc:creator>
      <dc:date>2022-02-01T06:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: wmi WQL query using hostname variable</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/wmi-WQL-query-using-hostname-variable/m-p/583266#M102771</link>
      <description>&lt;P&gt;No. As I wrote before, there is no templating within the config file.&lt;/P&gt;&lt;P&gt;Some specific values can have "template values" like decideonstartup mentioned by you but that only works for that particular variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 19:09:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/wmi-WQL-query-using-hostname-variable/m-p/583266#M102771</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-02-01T19:09:34Z</dc:date>
    </item>
  </channel>
</rss>

