Are there any examples for using PowerShell with the epagent out there?
I'd appreciate anything you have, thanks!
Here you go => PowerShell Collector Agent
Many thanks, Hiko!
I was excited to see a Windows Event log script but it's not quite was I was looking for so I started writing my own. I'm getting tripped up on passing the metric up to our EM, however.
What I'm looking to do is a quick and dirty scan the Windows application log for a specific event that may have occured in the last 5 minutes. This script gets me what I'm looking for but I'm getting the following error:
Bad metric data from .\wineventlog.ps1 - Exceptioncalling "createIntCounterDataRecorder" with "1" argument(s): "Metric_Name_Is_Badly_Formed[WinEvents|Application Log|]"
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,psEPA.ps1
Attached is the script I'm running. Any thoughts?
I'm looking into it now
You cannot have a colon in the metric path. APM specifically uses that character as the metric name/value separator.
Here is line 6 from your script:
$metric = 'WinEvents|Application Log|Errors|:Event 1022=' + $msgCount
Here is the same line from the example:
$metric = 'WinEvents|Application Log|' + $enum + ':Message=' + $metricValue
The issue lies with your metric name. It appears that you forgot to provide one before the colon.
You can either remove the pipe symbol before the colon or provide a metric name there.
I believe what you want to do is remove the pipe so you can this metric path, name, and value:
$metric = 'WinEvents|Application Log|Errors:Event 1022=' + $msgCount
domain|host|customprocess|agentname|WinEvents|Application Log|Errors:Event 1002 where 'Event 1002' is an IntCounter.
we had good results with the following:
In the IntroscopeEPAgent.properties:
[...].command=powershell -NoLogo -noninteractive -NoProfile -WindowStyle hidden -inputformat none -File "./epaplugins/path/myfile.ps1"
In the Powershell Script at the beginning:
$ErrorActionPreference = "SilentlyContinue"
$bufferSize = new-object System.Management.Automation.Host.Size 256,30
$Host.UI.RawUI.BufferSize = $bufferSize