Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

WMI Permanent event monitoring - Powerevents syntax problem

$
0
0

Hello,

I have been trying to come up with nice solution for permanent event monitoring and so far Powerevents seemed like nice way to go.

However I have a problem with Commandline consumer syntax, where I run another PS script.

Here is my Consumer command:

$consumer = New-WmiEventConsumer -Name "Event Consumer for $eventid" -ConsumerType commandline -CommandLineTemplate "powershell.exe -command `". 'c:\skript\monitoring\sql_vklad_eventy.ps1' `"$eventid $popis`""

Here it calls script that inserts its two parameters into SQL, which in this case are variables $eventid and $popis.

My problem is that second parameter is long string with event details in it and I can't manage to get it in quotation marks that doesn't screw up whole line. When I run the script, first parameter writes fine and I have only first word from the second one.

No matter what I do, I just break whole command or get same result.
Can you please help me ?


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>