<?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: Running multiply Powershell scripts at the same time in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Running-multiply-Powershell-scripts-at-the-same-time/m-p/509708#M86689</link>
    <description>&lt;P&gt;It seems the scripts shares the same run space some how. don't know what the best approach is to execute powershell scripts from splunks. seems like it causing a lot of trouble&lt;/P&gt;&lt;P&gt;here are some more error i get when receiving the exception from the scripts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script failed System.Management.Automation.RuntimeException: The following error occurred while loading the extended type data file: Error in TypeData "Sqlcollaborative.Dbatools.dbaSystem.DbatoolsExceptionRecord": The member SerializationDepth is already present.&lt;BR /&gt;Error in TypeData "Sqlcollaborative.Dbatools.dbaSystem.DbatoolsException": The member SerializationDepth is already present.&lt;BR /&gt;Error in TypeData "Microsoft.SqlServer.Management.Smo.Server": The member Invoke is already present.&lt;BR /&gt;Error in TypeData "Microsoft.SqlServer.Management.Smo.Server": The member Query is already present.&lt;BR /&gt;Error in TypeData "Microsoft.SqlServer.Management.Smo.Database": The member Invoke is already present.&lt;BR /&gt;Error in TypeData "Microsoft.SqlServer.Management.Smo.Database": The member Query is already present.&lt;/P&gt;&lt;P&gt;at System.Management.Automation.Runspaces.InitialSessionState.ThrowTypeOrFormatErrors(String resourceString, String errorMsg, String errorId)&lt;BR /&gt;at System.Management.Automation.Runspaces.InitialSessionState.UpdateTypes(ExecutionContext context, Boolean updateOnly)&lt;BR /&gt;at System.Management.Automation.Runspaces.InitialSessionState.Bind_UpdateTypes(ExecutionContext context, Boolean updateOnly)&lt;BR /&gt;at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly, PSModuleInfo module, Boolean noClobber, Boolean local)&lt;BR /&gt;at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly)&lt;BR /&gt;at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions&amp;amp; options, Boolean&amp;amp; containedErrors)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script failed System.Management.Automation.ActionPreferenceStopException: The running command stopped because the preference variable "WarningPreference" or common parameter is set to Stop: [15:00:05][Invoke-QueryRawDatabases] Failure | Method invocation failed because [Microsoft.SqlServer.Management.Smo.Server] does not contain a method named 'Query'.&lt;BR /&gt;at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)&lt;BR /&gt;at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)&lt;BR /&gt;at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)&lt;BR /&gt;at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jul 2020 13:36:11 GMT</pubDate>
    <dc:creator>Danny_Nilsson</dc:creator>
    <dc:date>2020-07-17T13:36:11Z</dc:date>
    <item>
      <title>Running multiply Powershell scripts at the same time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Running-multiply-Powershell-scripts-at-the-same-time/m-p/506646#M86249</link>
      <description>&lt;P&gt;I have been working the past 2 weeks with getting powershell scripts and cron jobs stable. but find that when i run 6 scripts into the input.conf, i causes issue on some of the scripts randomly. one of the errors is&lt;/P&gt;&lt;P&gt;"Collection was modified; enumeration operation may not execute"&lt;/P&gt;&lt;P&gt;The thing is the powershell script is running the same PS1 file where the parameter is almost identical. and when i restart the service the same error can come from one of the other script and the one just failed&lt;/P&gt;&lt;P&gt;At the moment i have been able to fix the issue with implementing a sleep in front of every script, and this seems to work, but are not the ideal solution&lt;/P&gt;&lt;P&gt;Here is the debug log with the sleep. in basic it a script using dbatools and run some queries.&lt;/P&gt;&lt;P&gt;I do an import of dbatools at the beginning, and for the output it also looks good in splunk when the script runs succesful.&lt;/P&gt;&lt;P&gt;I tried to do an ISE where i added all the same script lines as in the input.conf, but are unable to reproduce it no matte how much i want it to fail.&lt;/P&gt;&lt;P&gt;i also had some different approaches, to collect all the script info to a variable and output at the bottom&lt;/P&gt;&lt;P&gt;run as Dot, Source&lt;/P&gt;&lt;P&gt;Run as a isolated function with powershell command&lt;/P&gt;&lt;P&gt;The only thing that make it stable is the sleep.&amp;nbsp;&lt;/P&gt;&lt;P&gt;06-30-2020 10:45:00.0225972+2 INFO Start executing script=sleep 3; ."C:\Program Files\SplunkUniversalForwarder\etc\apps\xxx\Bin\Get-NCSQLDiagsplunk.ps1" -QueryIDs 35 -SqlInstance localhost -SplunkEnable for stanza=NCSQLDiag35&lt;BR /&gt;06-30-2020 10:45:00.0235980+2 INFO Start executing script=sleep 4; ."C:\Program Files\SplunkUniversalForwarder\etc\apps\xxx\Bin\Get-NCSQLDiagsplunk.ps1" -QueryIDs 46 -SqlInstance localhost -SplunkEnable for stanza=NCSQLDiag46&lt;BR /&gt;06-30-2020 10:45:01.3045026+2 INFO End of executing script=sleep 1; ."C:\Program Files\SplunkUniversalForwarder\etc\apps\xxx\Bin\Get-NCSQLDiagsplunk.ps1" -QueryIDs 27 -SqlInstance localhost -SplunkEnable for stanza=NCSQLDiag27, execution_time=1.2849084 seconds&lt;BR /&gt;06-30-2020 10:45:02.2756997+2 INFO End of executing script=sleep 2; ."C:\Program Files\SplunkUniversalForwarder\etc\apps\xxx\Bin\Get-NCSQLDiagsplunk.ps1" -QueryIDs 34 -SqlInstance localhost -SplunkEnable for stanza=NCSQLDiag34, execution_time=2.2541032 seconds&lt;BR /&gt;06-30-2020 10:45:03.3188309+2 INFO End of executing script=sleep 3; ."C:\Program Files\SplunkUniversalForwarder\etc\apps\xxx\Bin\Get-NCSQLDiagsplunk.ps1" -QueryIDs 35 -SqlInstance localhost -SplunkEnable for stanza=NCSQLDiag35, execution_time=3.295233 seconds&lt;BR /&gt;06-30-2020 10:45:04.1506740+2 INFO End of executing script=sleep 4; ."C:\Program Files\SplunkUniversalForwarder\etc\apps\xxx\Bin\Get-NCSQLDiagsplunk.ps1" -QueryIDs 46 -SqlInstance localhost -SplunkEnable for stanza=NCSQLDiag46, execution_time=4.127076 seconds&lt;BR /&gt;06-30-2020 10:45:07.3460828+2 INFO End of executing script=sleep 6; ."C:\Program Files\SplunkUniversalForwarder\etc\apps\xxx\Bin\Get-NCSQLDiagsplunk.ps1" -QueryIDs 102 -SqlInstance localhost -SplunkEnable for stanza=NCSQLDiag102, execution_time=7.3264873 seconds&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 08:52:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Running-multiply-Powershell-scripts-at-the-same-time/m-p/506646#M86249</guid>
      <dc:creator>Danny_Nilsson</dc:creator>
      <dc:date>2020-06-30T08:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Running multiply Powershell scripts at the same time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Running-multiply-Powershell-scripts-at-the-same-time/m-p/509708#M86689</link>
      <description>&lt;P&gt;It seems the scripts shares the same run space some how. don't know what the best approach is to execute powershell scripts from splunks. seems like it causing a lot of trouble&lt;/P&gt;&lt;P&gt;here are some more error i get when receiving the exception from the scripts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script failed System.Management.Automation.RuntimeException: The following error occurred while loading the extended type data file: Error in TypeData "Sqlcollaborative.Dbatools.dbaSystem.DbatoolsExceptionRecord": The member SerializationDepth is already present.&lt;BR /&gt;Error in TypeData "Sqlcollaborative.Dbatools.dbaSystem.DbatoolsException": The member SerializationDepth is already present.&lt;BR /&gt;Error in TypeData "Microsoft.SqlServer.Management.Smo.Server": The member Invoke is already present.&lt;BR /&gt;Error in TypeData "Microsoft.SqlServer.Management.Smo.Server": The member Query is already present.&lt;BR /&gt;Error in TypeData "Microsoft.SqlServer.Management.Smo.Database": The member Invoke is already present.&lt;BR /&gt;Error in TypeData "Microsoft.SqlServer.Management.Smo.Database": The member Query is already present.&lt;/P&gt;&lt;P&gt;at System.Management.Automation.Runspaces.InitialSessionState.ThrowTypeOrFormatErrors(String resourceString, String errorMsg, String errorId)&lt;BR /&gt;at System.Management.Automation.Runspaces.InitialSessionState.UpdateTypes(ExecutionContext context, Boolean updateOnly)&lt;BR /&gt;at System.Management.Automation.Runspaces.InitialSessionState.Bind_UpdateTypes(ExecutionContext context, Boolean updateOnly)&lt;BR /&gt;at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly, PSModuleInfo module, Boolean noClobber, Boolean local)&lt;BR /&gt;at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly)&lt;BR /&gt;at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions&amp;amp; options, Boolean&amp;amp; containedErrors)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script failed System.Management.Automation.ActionPreferenceStopException: The running command stopped because the preference variable "WarningPreference" or common parameter is set to Stop: [15:00:05][Invoke-QueryRawDatabases] Failure | Method invocation failed because [Microsoft.SqlServer.Management.Smo.Server] does not contain a method named 'Query'.&lt;BR /&gt;at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)&lt;BR /&gt;at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)&lt;BR /&gt;at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)&lt;BR /&gt;at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 13:36:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Running-multiply-Powershell-scripts-at-the-same-time/m-p/509708#M86689</guid>
      <dc:creator>Danny_Nilsson</dc:creator>
      <dc:date>2020-07-17T13:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Running multiply Powershell scripts at the same time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Running-multiply-Powershell-scripts-at-the-same-time/m-p/509709#M86690</link>
      <description>&lt;P&gt;just to say when adding a sleep; command in from of every script, over time they start to run successful&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 13:37:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Running-multiply-Powershell-scripts-at-the-same-time/m-p/509709#M86690</guid>
      <dc:creator>Danny_Nilsson</dc:creator>
      <dc:date>2020-07-17T13:37:17Z</dc:date>
    </item>
  </channel>
</rss>

