AEM CentraStage Event Result Script

Hi, 

We are using AEM CentraStage Monitoring as an monitoring tool. With this monitoring program we are trying to create e-mail notifications of the event log. 

To create the e-mail notifications we need to create an custom component. For the custom component we have written the following PowerShell script:

$Event = Get-WinEvent -FilterHashtable @{logname='Microsoft-Windows-Backup'; id=4,5,8,9,19,49;StartTime=(Get-Date).AddMinutes(-2015)} -MaxEvents 1 -ErrorAction SilentlyContinue | format-list

If ($Event -eq $null)
	{ Exit 0 } #No events logged
Else
{ 
Write-Host "<-Start Result->"
Write-Host "Result="($Event | Format-Table | Out-String)
Write-Host "<-End Result->"
Exit 1
}

But when we receive an e-mail notificiaton, the e-mail is empty
Like this: 

I have tried different variation in the script like removing the  format-list Command, but then we receive an e-mail notification with errors.

Like this


Can somebody help me out, Because i don't have enoug knowledge to resolve this problem on my own. 

Kind regard,
Francois Meulenberg


  • Edited by Francois013 22 hours 29 minutes ago wrong names
September 1st, 2015 4:43am

Change Write-Host to Write-Output.

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 7:00am

Try it this way:

$evttext=$Event | Format-Table | Out-String

$output=@" <-Start Result-> Result=$evttext <-End Result-> "@
Write-Output $output Exit 1


September 1st, 2015 7:03am

Here is how we would do this in PowerShell:

$tmplt=@'
<-Start Result->
Result={1}
<-End Result->
'@

# set filter for backup events for yesterday ONLY
$filter=@{
    logname='Microsoft-Windows-Backup'
    id=4,5,8,9,19,49
    StartTime=[datetime].AddDays(-1)
}

if($events=Get-WinEvent -FilterHashtable $filter -MaxEvents 1 -ErrorAction SilentlyContinue){
    Exit 0 #No events logged
}else{
    $evttext=$events | Format-Table | Out-String
    Write-Output ($tmplt -f $output)
    Exit 1
}

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 7:12am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics