I'm trying to get text from a Get-WinEvent messageblock, normally I simply use this to get the first sentence:
($_.Message).split(".")[0]
This works fine if the first part is seperated by a .
The Message-Block looks like this:
Remotedesktopdienste: Die Sitzungsanmeldung war erfolgreich: Benutzer: testlab\testuser.local Sitzungs-ID: 1 Quellnetzwerkadresse: LOKAL.
I try to extract only the part Remotedesktopdienste: Die Sitzungsanmeldung war erfolgreich: (including the : would be perfect, but not mandatory)
Simply using the : as delimiter did not work (the second part is missing).
After that, I tried to use
($_.Message).split(':',2)[0]
Should be the second : in the message-block, this gives Remotedesktopdienste
Another idea was to use
($_.Message).split('[\r\n]',2)[0]
to use the second new line, also no success with that, the result is Remotedesktopdie