<?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 Powershell Script on UF - high CPU Usage in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-on-UF-high-CPU-Usage/m-p/584008#M102832</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have 4 powershell scripts I wrote for MSSQL servers, simple Invoke-Query PS command to query the database health state (in terms of database running queries resources usage, etc) and send the output as JSON to splunk.&lt;/P&gt;&lt;P&gt;Those are really short scripts, and when running then manually from the server they run really fast.&lt;/P&gt;&lt;P&gt;But when the scripts runs from the input:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;script://runpowershell.cmd script_name.ps1​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It takes longer time for the scripts and the &lt;STRONG&gt;powershell.exe&lt;/STRONG&gt; process to end (1-2 minutes), and during that period the CPU is on 100% (viewing live from Task Manager, when the 4 powershell.exe processes are first in list when ordering by CPU usage, high first)&lt;/P&gt;&lt;P&gt;Can’t understand why.&lt;/P&gt;&lt;P&gt;Notes:&lt;/P&gt;&lt;P&gt;I use the common r&lt;STRONG&gt;unpowershell.cmd&lt;/STRONG&gt; script method to execute the powershell.exe with ExecutionPolicy Bypass flag to avoid errors running the script.&lt;BR /&gt;—&lt;/P&gt;&lt;P&gt;I’m aware of the SQL Server Add-on and the DB Connect method (I’ve took the SQL queries from the add-on templates, but I’m going to monitor hundreds of MSSQL Servers, and I didn’t want to configure hundreds of DB Connect connections and inputs for each server (the single HF is single point of failure for all MSSQL monitoring + performance + a lot of time to configure for hundreds of servers)&lt;/P&gt;&lt;P&gt;So I’m converting the DB connect SQL templates queries to PS scripts to deploy from DS, so each MSSQL UF will run the query locally and will send the output as to Splunk.&lt;/P&gt;</description>
    <pubDate>Mon, 07 Feb 2022 19:24:37 GMT</pubDate>
    <dc:creator>Bar_Ronen</dc:creator>
    <dc:date>2022-02-07T19:24:37Z</dc:date>
    <item>
      <title>Powershell Script on UF - high CPU Usage</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-on-UF-high-CPU-Usage/m-p/584008#M102832</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have 4 powershell scripts I wrote for MSSQL servers, simple Invoke-Query PS command to query the database health state (in terms of database running queries resources usage, etc) and send the output as JSON to splunk.&lt;/P&gt;&lt;P&gt;Those are really short scripts, and when running then manually from the server they run really fast.&lt;/P&gt;&lt;P&gt;But when the scripts runs from the input:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;script://runpowershell.cmd script_name.ps1​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It takes longer time for the scripts and the &lt;STRONG&gt;powershell.exe&lt;/STRONG&gt; process to end (1-2 minutes), and during that period the CPU is on 100% (viewing live from Task Manager, when the 4 powershell.exe processes are first in list when ordering by CPU usage, high first)&lt;/P&gt;&lt;P&gt;Can’t understand why.&lt;/P&gt;&lt;P&gt;Notes:&lt;/P&gt;&lt;P&gt;I use the common r&lt;STRONG&gt;unpowershell.cmd&lt;/STRONG&gt; script method to execute the powershell.exe with ExecutionPolicy Bypass flag to avoid errors running the script.&lt;BR /&gt;—&lt;/P&gt;&lt;P&gt;I’m aware of the SQL Server Add-on and the DB Connect method (I’ve took the SQL queries from the add-on templates, but I’m going to monitor hundreds of MSSQL Servers, and I didn’t want to configure hundreds of DB Connect connections and inputs for each server (the single HF is single point of failure for all MSSQL monitoring + performance + a lot of time to configure for hundreds of servers)&lt;/P&gt;&lt;P&gt;So I’m converting the DB connect SQL templates queries to PS scripts to deploy from DS, so each MSSQL UF will run the query locally and will send the output as to Splunk.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2022 19:24:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-Script-on-UF-high-CPU-Usage/m-p/584008#M102832</guid>
      <dc:creator>Bar_Ronen</dc:creator>
      <dc:date>2022-02-07T19:24:37Z</dc:date>
    </item>
  </channel>
</rss>

