Why is my Event Log Name, Source, and other properties blank? - powershell

I am creating an event log with PowerShell using the following command:
New-EventLog -LogName "TestLog" -Source "TestLog_Source"
The log gets created but all of its properties are blank.
I've tried removing the log and re-running the command and it has not worked.
Log Name:
Source:
Event ID:
Level:
User:
OpCode:
More information: Event Log Online Help
I also notice that the application is not actually logging anything to the log either. The above is what the first column of the event log properties at the bottom shows me. There are other event logs on the server that show those values populated.

Related

Rundeck show log flag as error but it's not

I got a question about log output on rundeck.
I've cron a multiple oracle EXPDP and all the log are flagged as ERROR but it's not.
I've try to put a log handler but i don't understand how to dot it.
My job:
export ORACLE_PDB_SID=XXXXXXXX
expdp "/ as sysdba" schemas=XXX#option.CODE#SCH001 directory=DUMPSTORAGE_PROD dumpfile=#option.CLIENT##option.CODE#SCH001"date +"%d-%m-%Y"".dump logfile=#option.CLIENT#expdp#option.CODE#SCH001.log job_name=#option.CLIENT#
gzip -9 /mnt/DUMPSTORAGE/#option.CLIENT##option.CODE#SCH001"date +"%d-%m-%Y"".dump &&\
SCREENSHOT

Parsing Windows Defender event log in PowerShell

I need to parse Windows Defender event log. With this command
Get-WinEvent -LogName "Microsoft-Windows-Windows Defender/Operational" | Where-Object { $_.LevelDisplayName -ne "Information" } | Select-Object -ExpandProperty Message
I get this output:
Windows Defender Antivirus has detected malware or other potentially unwanted software.
For more information please see the following:
https://go.microsoft.com/fwlink/?linkid=37020&name=Trojan:Win32/TFTPD32&threatid=12892&enterprise=0
Name: Trojan:Win32/TFTPD32
ID: 12892
Severity: Severe
Category: Trojan
Path: file:_\\server\share\path\file1.exe::$DATA; file:_\\server\share\path\file2.exe::$DATA; file:_\\server\share\path\file3.exe::$DATA;
Detection Origin: Network share
Detection Type: Concrete
Detection Source: Real-Time Protection
User: DOMAIN\user
Process Name: C:\Windows\SMSProxy\Microsoft.StorageMigration.Proxy.Service.exe
Signature Version: AV: 1.335.1263.0, AS: 1.335.1263.0, NIS: 1.335.1263.0
Engine Version: AM: 1.1.18000.5, NIS: 1.1.18000.5
When there are multiple files and the line starting with Path: is very long, it is truncated. Not the message property, but only the line.
When I see the record using Event Log viewer, the line is complete.
Is there a way to get full length of the line?
I need to get lines with Name: and Path: from the Message property (multi-line string) only.
How can I get it using e.g. RegEx ^\s+(Name|Path): ?
Update:
I mishmatched event log records, even in Event Log the line Path is truncated.
The second part of the question remains: How to get only some lines from multiline property?

For some reason, a warning is issued when calling the procedure SYSPROC.ADMIN_CMD ('EXPORT to ...')

I have the following problem:
I am using the following command:
EXPORT TO "D:\ExportFiles\ACTIVATE_DICT.csv" OF DEL MODIFIED BY TIMESTAMPFORMAT="YYYY/MM/DD HH:MM:SS" STRIPLZEROS MESSAGES "D:\ExportFiles\FMessage.txt" SELECT * FROM DB2INST4.ACTIVATE_DICT;
In the Command Editor of the program, the Control Center successfully exported data from the ACTIVATE_DICT table to a CSV file ACTIVATE_DICT.csv.
But for a number of reasons, I need you to execute this command in the IBM Data Studio or DataGrip program, and there it cannot be executed in this form.
Therefore, I read the following manual enter link description here
and based on it wrote the following command:
CALL SYSPROC.ADMIN_CMD('EXPORT to /lotus/ExportFiles/ACTIVATE_DICT.csv OF DEL MODIFIED BY TIMESTAMPFORMAT="YYYY/MM/DD HH:MM:SS" STRIPLZEROS MESSAGES /lotus/ExportFiles/FMessage.txt SELECT * FROM DB2INST4.ACTIVATE_DICT');
Here is the message on the result of the command:
[2018-10-11 15:15:23] [ ][3107] There is at least one warning
message in the message file.. SQLCODE=3107, SQLSTATE= ,
DRIVER=4.23.42 [2018-10-11 15:15:23] 1 row retrieved starting from 1
in 75 ms (execution: 29 ms, fetching: 46 ms)
And in the / lotus / ExportFiles / directory there is no ACTIVATE_DICT.csv file and there is no FMessage.txt file in the / lotus / ExportFiles / directory.
Question: How then to correctly execute this command ??? Maybe I'm doing something wrong?
sqlcode 3107 is a warning message:
SQL3107W At least one warning message was encountered during LOAD processing.
Explanation
You can load data into a database from a file, tape, or named pipe using the LOAD command. You can specify that any warnings or errors from the LOAD processing be printed to a message file. If no message file is specified, the warnings or errors are printed to standard out (unless the database manager instance is configured as a partitioned-database environment.)
It is to tell you to read message log in the message file you specified. In your case: /lotus/ExportFiles/FMessage.txt
Please read into the file to see what error is logged and if you need help understand what is logged, please post the content of the file.
This message is returned when at least one warning was received during processing. If a message file is being used, the warnings and errors will be printed there.
This warning does not affect processing.
User response
Review the message file warning.
EXPORT command using the ADMIN_CMD procedure
See use of the 'MESSAGES ON SERVER' clause, and how to get these messages using the result set returned by this routine in this case.

Remove-S3Bucket : The specified bucket does not exist

I had created 3 buckets for testing and then later on deleted via PowerShell Command as below:
Get-S3Bucket| select -Skip 1 | foreach {Remove-S3Bucket -BucketName $_.Bucketname -DeleteBucketContent}
However, after couple of hours, I run Get-S3Bucket and I see the same buckets listed. I checked the console and found 3 buckets already there. I tried opening one of them and got "Data Not Found" error as per this screenshot:
Link:[https://onedrive.live.com/?cid=AE48A34880F3B8E4&id=AE48A34880F3B8E4%21142505&parId=AE48A34880F3B8E4%21111&o=OneUp]
I thought it might be a stale object, so tried creating another with the same name and it won't let me create one saying 'bucket already exists', as per below screenshot:
Link:[https://onedrive.live.com/?cid=AE48A34880F3B8E4&id=AE48A34880F3B8E4%21142504&parId=AE48A34880F3B8E4%21111&o=OneUp]
I tried again removing it from PowerShell, and get this error "The specified bucket does not exist", below screenshot:
Link:[https://onedrive.live.com/?cid=AE48A34880F3B8E4&id=AE48A34880F3B8E4%21142506&parId=AE48A34880F3B8E4%21111&o=OneUp]
Can someone suggest anything?
-kt

How to create NTEventlogAppender.dll as required for logging event in the eventlog using log4cplus

First, Let me thank for the log4cplus source code.
I am facing one issue as follows:
What I am trying to do?
I want to log the messages to event log on windows.
What did I do?
I could get the event logging enabled by in including following .h
#include <log4cplus/nteventlogappender.h>
And creating the appender as follows:
SharedAppenderPtr append_3(new NTEventLogAppender(LOG4CPLUS_TEXT("127.0.0.1"), LOG4CPLUS_TEXT("log"), LOG4CPLUS_TEXT("source")));
append_3->setName(LOG4CPLUS_TEXT("ToEventlog"));
Logger to_eventlog = Logger::getInstance(LOG4CPLUS_TEXT("to_eventlog"));
to_eventlog.addAppender(append_3);
to_eventlog.setLogLevel(log4cplus::ALL_LOG_LEVEL);
And logging as
Logger to_eventlog = Logger::getInstance(LOG4CPLUS_TEXT("to_eventlog"));
LOG4CPLUS_FATAL(to_eventlog, “Test Message.”);
When I log the message, I get following in the event log:
The description for Event ID 4096 from source source cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
Test Message.
the message resource is present but the message is not found in the string/message table
I tried to create a dll with name NTEventLogAppender.dll with string table resource and a string with id 4096 (as hardcoded in the nteventlogappender.cxx file in log4cplus) and compiled it with resource only dll (/NOENTRY) but I still keep getting above error.
I already tried question to log4cplus-devel#lists.sourceforge.net but did not get any answer yet.
Any help on how to create this dll would be greatly appreciated.
Thanks.
This is how I resolved this issue:
comipiled NTEventLogAppender.mc file using commands:
mc -U NTEventLogAppender.mc
rc -r NTEventLogAppender.rc
link -dll -noentry -out:NTEventLogAppender.dll NTEventLogAppender.res
where NTEventLogAppender.mc has following contents
MessageIdTypedef=DWORD
SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS
Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
Warning=0x2:STATUS_SEVERITY_WARNING
Error=0x3:STATUS_SEVERITY_ERROR
)
FacilityNames=(System=0x0:FACILITY_SYSTEM
Runtime=0x2:FACILITY_RUNTIME
Stubs=0x3:FACILITY_STUBS
Io=0x4:FACILITY_IO_ERROR_CODE
)
LanguageNames=(English=0x409:MSG00409)
; // The following are message definitions.
MessageId=0x1000
SymbolicName=SVC_TEST
Language=English
A message for something.
.
; // A message file must end with a period on its own line
; // followed by a blank line.
copied the NTEventLogAppender.dll to c:\windows\system32
and ran the above mentioned test program and found that event log found the message resource correctly.
you need to register this dll by copying following in .reg file and running the same
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\log\source]
"EventMessageFile"="C:\\windows\\system32\\NTEventLogAppender.dll"
"CategoryMessageFile"="C:\\windows\\system32\\NTEventLogAppender.dll"
"TypesSupported"=dword:00000007
"CategoryCount"=dword:00000005