I want to change the default output of get-winevent to look like this in powershell 5.1, so the header says the LogName instead of ProviderName.
get-winevent application -MaxEvents 1
LogName: Application
TimeCreated Id LevelDisplayName Message
----------- -- ---------------- -------
8/23/2020 10:32:25 AM 0
I can do this very easily in powershell 7, by editing Event.format.ps1xml somewhere under $PSHOME:
<ViewSelectedBy>
<TypeName>System.Diagnostics.Eventing.Reader.EventLogRecord</TypeName>
</ViewSelectedBy>
<GroupBy>
<PropertyName>LogName</PropertyName>
<Label>LogName</Label>
</GroupBy>
But in powershell 5.1, after changing the ownership and security so I can write to that file, the same change seems to have no effect! It seems like get-winevent ignores that file completely. How can I make this change?
cd $pshome
takeown /f Event.Format.ps1xml /a
icacls event.format.ps1xml /grant administrators:w
I think this format is defined in c# somewhere? Remove generated types and formats for Microsoft.PowerShell.Diagnostics #1218