Forum Discussion
10 years ago
provides proper JSON for the script eventsource (though that appears to not like to pass parameters for tokens, so unable to use as well).
$events = Get-WinEvent -ComputerName $hostname -Credential $remotecredential -LogName Application
if ($events) {
$arr=@{}
$arr["events"] = @{}
$arr.events = $events | Select-Object @{Name = "happenedOn"; Expression = {$($_.TimeCreated.ToUniversalTime().ToString("ddd MMM dd hh:mm:ss UTC yyyy"))}}, @{Name = "Severity"; Expression = {"error"}}, message, @{Name = "Source"; Expression = {$_.ProviderName}}
$output = $arr | ConvertTo-Json -Compress
write-host $output
}
Related Content
- 11 months ago
- 2 years ago